PHP Spintax Function - The PHP Spinner!
|
I found this great code on the net to spin text, a PHP Spintax function. The function is incredibly easy and just as easy to use.
/* * Take some text and spin it, then return * spun verison. */ function ParseSpinText($s) { preg_match('{(.+?)}#is',$s,$m); if(empty($m)) return $s; $t = $m[1]; if(strpos($t,'{')!==false){ $t = substr($t, strrpos($t,'{') + 1); } $parts = explode("|", $t); $s = preg_replace("+{".preg_quote($t)."}+is", $parts[array_rand($parts)], $s, 1); return ParseSpinText($s); } Usage //Example: echo ParseSpinText('{This|Here} is {some|a {little|wee} bit of} {example|sample} text.'); Origianl Source Here |
Replies:
|
||
|























