PHP 8.4.24 Released!

Voting

: one minus one?
(Example: nine)

The Note You're Voting On

qeremy [atta] gmail [dotta] com
14 years ago
A proper unicode string shuffle;

<?php
function str_shuffle_unicode($str) {
    $tmp = preg_split("//u", $str, -1, PREG_SPLIT_NO_EMPTY);
    shuffle($tmp);
    return join("", $tmp);
}
?>

$str = "Şeker yârim"; // My sweet love

echo str_shuffle($str); // i�eymrŢekr �

echo str_shuffle_unicode($str); // Şr mreyeikâ

<< Back to user notes page

To Top