Your own article spinner in PHP!

phpbuilt

Account compromised December 2025
Joined
May 16, 2011
Messages
1,865
Reaction score
5,369
PHP:
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;
}
function str_replaceFirst($s,$r,$str){
    $l = strlen($str);
    $a = strpos($str,$s);
    $b = $a + strlen($s);
    $temp = substr($str,0,$a) . $r . substr($str,$b,($l-$b));
    return $temp;
}
function inStr($needle, $haystack){
    return @strpos($haystack, $needle) !== false;
}
Pass any block of text to the function "spin" and it will return your article, spun. Great for anyone who is developing their own system involving article spinning.

Supports nested spinning to infinite levels.

If you're sending articleranks.com spins to it, just convert "[" and "]" to "{" "}" ... and "~" to "|".

BTW I wrote this myself. Use it however you want. Let me know if you have any questions.

Enjoy!
 
Last edited:
cool man nice share, can you explain how it works?

is it replacing a & b with different a & b characters?
 
cool man nice share, can you explain how it works?

is it replacing a & b with different a & b characters?

It works just like The Best Spinner or Spinner Chief for taking an article spin and turning it into a finished spun article.

This code will allow you to use spun articles in your own programming. For instance, if you are writing your own software to send spun articles to wordpress blogs or bookmarking services ... this function will enable your software to spin articles as it submits.

The Best Spinner has a port on it that people have to run it as a service so their software can receive spun text. The above function will allow you to bypass the need to do that, now you can spin right in your own programming.

I use it in software I'm writing to automatically generate articles and send them to wordpress blogs and social bookmarking. Anyone doing that sort of thing will find this function very helpful.

Just to be clear, this is not something made to replace The Best Spinner or Spinner Chief. Theoretically you could take this and hook a thesaurus up to it and some ajax to make your own versions of those software, but that's not what I use it for. I simply use it to spin articles in my own programming code.
 
Last edited:
For guys who aren't experienced with programming what this script do is:

You have a text like:
{A|B|C} likes {C|D} but not {E|F}

After using this script you'll get :
A likes D but not E
C likes C but not F , etc
 
PHP:
<?php
set_time_limit(10);
function inStr($needle, $haystack){
    return @strpos($haystack, $needle) !== false;
}
function str_replaceFirst($s,$r,$str){
    $l = strlen($str);
    $a = strpos($str,$s);
    $b = $a + strlen($s);
    $temp = substr($str,0,$a) . $r . substr($str,$b,($l-$b));
    return $temp;
}
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;
}

echo '<form action="" method="post"><textarea name="mypost" cols="80" rows="20">';

if(isset($_POST["mypost"])){
    echo $_POST["mypost"];
}
echo '</textarea><br /><input name="" type="submit" /></form>';

if(isset($_POST["mypost"])){
    $mypost = $_POST["mypost"];
    $mypost = str_replace("'","`",$mypost);
    $echoMe = spin($mypost);
    $wordCount = explode(" ",$echoMe);
    $wordCount = count($wordCount);
    $echoMe = str_replace(chr(13).chr(10),"<br />".chr(13).chr(10),$echoMe);
    echo $echoMe;
    echo "<br />";
    echo "wordcount: <b>$wordCount</b>";

}

?>

Save that file on any php server, paste in your article spin and click submit. I'll show the spun content below the text box.
 
wow nice dude, thanks a lot, is it possible to make a feature here something like bulk spin and export? or something like remove original like TBS?
 
wow nice dude, thanks a lot, is it possible to make a feature here something like bulk spin and export? or something like remove original like TBS?

The code above I have this line of PHP:

PHP:
    $echoMe = spin($mypost);
You could put that in a loop, save it as a text file with PHP. If you don't know PHP, just google for "php loop" and "php save file" will get you on the right track.

But doesn't TBS or Spinner Chief have bulk exports that do this? The code above isn't really meant to replace either TBS or SC, it's made so you don't have to rely on either of those to take your finished spin and incorporate it into your own programming.

For instance, I have built an XMLRPC submit tool that will post to any wordpress blog remotely. Using XMLRPC, you can schedule your posts. So, assuming you had the logins to 100 blog logins and each of those blogs have XMLRPC enabled, you could loop a spin 100 times, submitting to each of the blogs. This becomes a pain in the butt though ... if your code can't do the spin itself and has to rely on TBS or SC ... its much easier if your code can handle the spin before it sends to your blogs. That is why I wrote this for myself ... and there's dozens of opportunities like this to use the code in building linkwheels or networks.
 
Last edited:
Does anyone have a synonym list for this software?

The only reason you would need one is if you were intending to completely reprogram a web application similar to The Best Spinner or Spinner Chief, getting your hands on a thesaurus would only be the first step in a very long journey.

The software above wasn't designed to help you create your spins. Its for using already finished spins.

For instance ...

Right now I'm programming an XMLRPC application to schedule posting articles to hundreds of wordpress blogs. Before the XMLRPC application sends the article, it creates it from spinner format into a readable article. Without the software I posted in original post, I wouldn't be able to spin the post before it got sent. That's what I use it for.

Every place that accepts spun articles, like seolinkvine, articleranks, etc. ... every single one of them have a function for spinning your article. In other words, if you want to create a service like articleranks ... you need a function to spin text. That's what the PHP function I created does.

Very few people will be helped by this post I'm sure (few people have need of a PHP spinner, everyone else can just use TBC or SC), but those few people I'm sure will be appreciative.
 
Thanks for the code - I plugged in a thesaurus and tried to get it to write the spintax for me - but the quality came out pretty bad, got to figure out a way to refine it:

Original:
Right now I'm programming an XMLRPC application to schedule posting articles to hundreds of wordpress blogs. Before the XMLRPC application sends the article, it creates it from spinner format into a readable article. Without the software I posted in original post, I wouldn't be able to spin the post before it got sent. That's what I use it for.

Right now I`m programming an XMLRPC application to make assignments ordainment articles to hundreds of wordpress Before the XMLRPC adhesive tape sends the passage it creates it from lime pattern into a legible externally the software I set in crucial keep score I wouldn`t be able to spin the post up to it got That`s what I use it for.

I have to work on how it treats punctuations and get a better word base.
 
Last edited:
thanks for this it is really helpful. Anyway is it ok for me to ask a script of this that can spin articles using my own list of synonyms?. I understand if you can't give us a script like that if you think that what I'm asking is too much...

Thanks and Rep given.. ^_^
 
That's really cool, glad the code actually helped someone!

I don't think it'll be that easy to automatically create spins based on a thesaurus ... the problem is various words have different meanings and it isn't easy to know which version is necessary.

If you're that good of a programmer, might be a better idea to use programming to scrape various translation services to convert text from one language to another. Language software is built to understand the grammar and can usually lead to appropriate synonym replacements.

I'm just trying to set myself up with hundreds of blogs, web2.0 properties and article directory accounts and send a spin article to each of them ... I just make the spins using regular spin software and use the code in the PHP to spin it before I post it.
 
thanks for this it is really helpful. Anyway is it ok for me to ask a script of this that can spin articles using my own list of synonyms?. I understand if you can't give us a script like that if you think that what I'm asking is too much...

Thanks and Rep given.. ^_^

Hmm, I'm not sure we're on the same page regarding what this script does. From the sound of your question, it seems as though you think it has the ability to take an un-spun article, and from that automatically create spin syntax inserting synonyms from a thesaurus. It doesn't do that at all.

It does the exact opposite -- it takes an already existing spin and turns it into an article.

I don't think its possible to take an article written in English and to automatically swap out synonyms on autopilot and still have it be readable -- if that could be done, TBS would have it by now (really anyone would make a fortune if they could do this).

In reality, your "own list of synonyms" would be inserted into your finished spin syntax. In other words, if you use TBS or SC to create a spun article using a human created spun article that has all the appropriate synonyms chosen for every word ... that spin will work perfect in the PHP spinner. Then you can take your spin and do whatever you want to with it with programming (such as write automatic posting software).

Not sure I answered your question properly, so if you still have a question let me know.
 
Last edited:
oh sorry I taught that this script is for spinning un-spun articles as what you're title is saying "Your own article spinner in PHP!" I might misunderstood it though.
 
Back
Top