Hi,
I am using this function which is
used to spin text.
Currently it looks to me like it is selected an
element from the $tStringToken array at random.
These two lines seem to be doing that:
I would like to change this so that it goes sequentially through
all of the available elements in the array and then when finished
starts again with the first element of the array.
But I am having trouble working it out.
This is the function I am working on.
Any ideas on how I can do this would be very helpful
Thanks.
.
I am using this function which is
used to spin text.
Currently it looks to me like it is selected an
element from the $tStringToken array at random.
These two lines seem to be doing that:
Code:
$i = rand(0,$tStringCount); $replace = $tStringToken[$i];
all of the available elements in the array and then when finished
starts again with the first element of the array.
But I am having trouble working it out.
This is the function I am working on.
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;
}
Thanks.
.
Comment