Code:
function spin($pass){
$mytext = $pass;
while(inStr("}",$mytext)){
$rbracket = strpos($mytext,"}",0);
$tString = substr($mytext,0,$rbracket);
$tStringToken = explode("{",$tString);
$tStringCount = count($tStringToken) - 1;
$tString = $tStringToken[$tStringCount];
$tStringToken = explode("|",$tString);
$tStringCount = count($tStringToken) - 1;
$i = rand(0,$tStringCount);
$replace = $tStringToken[$i];
$tString = "{".$tString."}";
$mytext = str_replaceFirst($tString,$replace,$mytext);
}
return $mytext;
}
Code:
$s = spin("{spin|spun} {stuff|shit}");