PHP script for Spin Text??

putrasandy

Regular Member
Joined
Sep 26, 2010
Messages
219
Reaction score
11
Hi, does anyone knows custom PHP script or other tool to do easy spinning like this:

alex
robert
jane
nicolas
martha
andy

becoming like this:
{alex|robert|jane|nicolas|martha|andy}

I can do it manually with notepad, but wondering the best way to automate this become more effective n efficient..
Note: i just want little, tiny tools...


Thanks
 
Last edited:
Here you go, a very basic text spin function:
PHP:
<?php

function spinText($text){
	$test = preg_match_all("#\{(.*?)\}#", $text, $out);

	if (!$test) return $text;

	$toFind = Array();
	$toReplace = Array();

	foreach($out[0] AS $id => $match){
	$choices = explode("|", $out[1][$id]);
	$toFind[]=$match;
	$toReplace[]=trim($choices[rand(0, count($choices)-1)]);
	}

	return str_replace($toFind, $toReplace, $text);
}

echo spinText("Hello {world|BHW}!");;

?>
 
Here you go, a very basic text spin function:
PHP:
<?php

function spinText($text){
    $test = preg_match_all("#\{(.*?)\}#", $text, $out);

    if (!$test) return $text;

    $toFind = Array();
    $toReplace = Array();

    foreach($out[0] AS $id => $match){
    $choices = explode("|", $out[1][$id]);
    $toFind[]=$match;
    $toReplace[]=trim($choices[rand(0, count($choices)-1)]);
    }

    return str_replace($toFind, $toReplace, $text);
}

echo spinText("Hello {world|BHW}!");;

?>

Hi, how this script work? I did upload to my host then run it. But nothing to work.. am I did it wrong?

is the php meant to DO the spnning or just put it into spintax format?
Not spinning, just convert to spintax format. any clue?
I have know nothing about php :D
 
Hi, how this script work? I did upload to my host then run it. But nothing to work.. am I did it wrong?


Not spinning, just convert to spintax format. any clue?
I have know nothing about php :D

Ahh.. I misunderstood what you were asking for. That PHP will do the spinning.

Why do you want a PHP solution? IMO for any type of simple text manipulation like that it's gonna be way easier to just use notepad++ or something similar. Find and replace the line breaks with pipes and wrap it in curly brackets. KISS :D
 
Ahh.. I misunderstood what you were asking for. That PHP will do the spinning.

Why do you want a PHP solution? IMO for any type of simple text manipulation like that it's gonna be way easier to just use notepad++ or something similar. Find and replace the line breaks with pipes and wrap it in curly brackets. KISS :D

Ah.. I use notepad++ everyday.. that's why I ask.lol... i want to automate it, cause i working on spintax everyday..
 
themidiman putrasandy I'm Sorry to bump this old thread .. but can you guys re-upload this tool if you still have it ?
 
Back
Top