note 129056 added to function.str-shuffle
| From: | bob0514 at main dot php dot net | Date: | Sun, 19 Nov 2023 13:18:35 +0000 |
| Subject: | note 129056 added to function.str-shuffle | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-221010@lists.php.net to get a copy of this message | ||
// Universal and simple function
<?php
function mb_str_shuffle($str){
$arrChars = mb_str_split($str);
shuffle($arrChars);
$shuffleStr = implode($arrChars);
return mb_strtolower($shuffleStr);
}
?>
EXAMPLE for use:
<?php
function mb_str_shuffle($str){
$arrChars = mb_str_split($str);
shuffle($arrChars);
$shuffleStr = implode($arrChars);
return mb_strtolower($shuffleStr);
}
$str = 'ÐÑÐ¸Ð²ÐµÑ ÐºÐ°Ðº дела?';
$arr = explode(' ', $str);
foreach ($arr as $word) {
echo mb_str_shuffle($word) . ' ';
}
OUTPUT: иеÑÐ²Ð¿Ñ ÐºÐºÐ° ?аедл
----
Server IP: 45.112.84.4
Probable Submitter: 45.91.157.134 (proxied: 37.214.26.199)
----
Manual Page -- https://php.net/manual/en/function.str-shuffle.php
Edit -- https://main.php.net/note/edit/129056
Del: integrated -- https://main.php.net/note/delete/129056/integrated
Del: useless -- https://main.php.net/note/delete/129056/useless
Del: bad code -- https://main.php.net/note/delete/129056/bad+code
Del: spam -- https://main.php.net/note/delete/129056/spam
Del: non-english -- https://main.php.net/note/delete/129056/non-english
Del: in docs -- https://main.php.net/note/delete/129056/in+docs
Del: other reasons-- https://main.php.net/note/delete/129056
Reject -- https://main.php.net/note/reject/129056
Search -- https://main.php.net/manage/user-notes.php