PHP text spinner

need a text spinner. basic features are an input box where person can enter their text using the following spinner syntax.

the {road|street} is {long|lengthy}

we would like the spinner strings to be multi level (nestable). Example

the {{road|street} is {long|lengthy}|{house|home} is {big|large}}

clicking submit would spit out the variations. You could put a limiter on this, such as up to 50 variation texts. would also like an option for the user to upload a .txt file containing their text if they already have it written out.

here is some code I found that will help with the project

function spin($text) {

//While there's pairs of square brackets, spin whats inside of them
while (!(strpos($text,'[') === FALSE) && !(strpos($text,']') === FALSE)) {

//Find the first '['
$leftb = strpos($text,'[');

//Find the first ']'
$rightb = strpos($text,']');

//Split the string up, then (psudo)randomise the item chosen
$spintext = split(',',substr($text,$leftb+1,$rightb-$leftb-1));
$spinselect = trim($spintext[mt_rand(0,count($spintext)-1)]);

//Get the whole string to replace including the brackets
$brackettext = substr($text,$leftb,($rightb-$leftb)+1);

//Replace the [blah,blah2] with whatever item is chosen
$text = str_replace($brackettext,$spinselect,$text);


//return the block of modified text
return $text;


can be seen working here:

this is still not nestable though

Taidot: PHP

Näytä lisää: text spinner, php text spinner, spinner syntax, php input spinner, php spinner, php multi level text spinner, php text spinning, php string functions substr text, php website upgrade, street 3, php multi, php level 3, multi variation, php multi file, multi php, upload file multi, php file upload multi, text using, php house, multi option, multi level user php, large text box, Variation, php level, enter text

Tietoa työnantajasta:
( 28 arvostelua ) Olympia, United States

Projektin tunnus: #427921

Myönnetty käyttäjälle:


Complete recursive job is ready! :) see pm. Thanks, Naveed

$30 USD 0 päivässä
(52 Arvostelua)

5 freelanceria on tarjonnut keskimäärin %project_bid_stats_avg_sub_26% %project_currencyDetails_sign_sub_27% tähän työhön


Hi, I can create multilevel text spinner. I will use your examples for testing purpose. I can install my work on your server. -- Sergey aka TakeReal

$70 USD 2 päivässä
(1254 arvostelua)

Hi, Please check PM

$125 USD 2 päivässä
(44 arvostelua)

Be glad to commit to this for you. Check pm if you can.

$140 USD 2 päivässä
(7 arvostelua)

Please see my private message.

$50 USD 1 päivässä
(3 arvostelua)