String Scrambler
The following funtion is used to convert the given string into randomized order
<?php
function String_Scramble($string)
{
$arr1 = array();
$output = ‘’;
$len = strlen($string);
for ($i = 0; $i < $len; $i++)
{
$rand = rand(0, $len);
while (isset($arr1[$rand]))
$rand = rand(0, $len);
$output .= $string[$rand];
$arr1[$rand] = true;
}
return $output;
}
// Example usage
echo String_Scramble(”Sample text”);
?>
In above example, String_Scramble is the funtion which will shuffle input string. In String_Scramble funtion, we can use rand() funtion to fetch random values from input string.
