Re: Multiple words str_shuffle
| From: | Jochem Maas | Date: | Tue, 08 Jul 2008 03:15:41 +0000 |
| Subject: | Re: Multiple words str_shuffle | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-276427@lists.php.net to get a copy of this message | ||
Jochem Maas schreef:
</snip>
this is a little better:
<?php
// $argv[1] is the first script argument on the CLI
$phrase = isset($argv[1]) && is_string($argv[1]) ? $argv[1] : 'The rain. in Spain falls, mainly "on" the plain!';
$phrase = preg_replace_callback('#(\w+)#', 'mixit', str_replace(" ", " ", $phrase));
function mixit($m)
{
return trim(chunk_split(str_shuffle(strtoupper($m[1])),1,' '));}