Say I have a text string: {a|b|c|d} {a|b|c|d} {a|b|c|d} {a|b|c|d}
.
And simple PHP function to shuffle the text:
function fb_filter_shuffle($string)
{
if(empty($string))
{
return NULL;
}
return preg_replace_callback('/\{.*?\}/i', function($m)
{
$options = explode('|', mb_substr($m[0], 1, -1));
shuffle($options);
return current($options);
}, $string);
}
I need to get all possible variations of the output. But how? the only option I came up so far, was to run the code nnn
times and pick the unique options. Any more efficient suggestions?
30 seconds with Google and look what I came up with ;)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.