At the minute I am able to spin articles but I have to create a list of arrays for certain words and then echo a random word from the array to give a spun effect. How would I go about in PHP making it so that if I just put in the following it would spin the text? "I wear a {yellow|green|blue} {coat|jacket|T shirt}" I have looked on the net but can't seem to find anything.
<?php $input = array("Neo", "Morpheus", "Trinity", "Cypher", "Tank"); function randomWord($input){ shuffle($input); return $input[0]; } echo "My matrix hero is ". randomWord($input); ?> PHP:
More specific..... <?php $colour = array("yellow", "green", "blue"); $item = array("coat", "jacket", "t-shirt"); function randomWord($input){ shuffle($input); return $input[0]; } echo "I wear a ". randomWord($colour) . " " . randomWord($item); ?> PHP:
Thanks for the reply, I can do it with that but how to I make it so I can just use the universal spinning syntax so that when something is within the tags it puts it into arrays?
<?php $text = 'I wear a {yellow|green|blue} {coat|jacket|T shirt}. My mother is very {nice|mad} to me. I wish I could do things as that { but why. I like doing things that do not make sense}. {}'; preg_match_all('/\{(.*[|].*)\}/Uis',$text,$result); foreach($result[1] as $curItem) { $curArray = explode('|',$curItem); $curItem = '{'.$curItem.'}'; $arrayCount = count($curArray); $text = str_replace($curItem,$curArray[rand(0,$arrayCount-1)],$text); } echo $text; ?> PHP: This should do it.