Jignasa Naik
Filed under - PHP
No Comments so far. Add yours now

Very good function for text spinning:

function spin($s){
if(empty($m)) return $s;

$t = $m[1];

$t = substr($t, strrpos($t,’{‘) + 1);

$parts = explode(“|”, $t);
$s = preg_replace(“+{“.preg_quote($t).”}+is”, $parts[array_rand($parts)], $s, 1);

return spin($s);

echo spin(‘{This|Here} is {some|a {little|wee} bit of} {example|sample} text.’);

Tags: ,

Leave your comment

You must be logged in to post a comment.

Share IT © 2018. All rights reserved.