I was doing some SEO for an excellent site on Friday. Their on-page was excellent, and they had some desirable backlinks. One problem they did have though was duplicate content on their location-specific “doorway” pages - pages designed to rank for “Blue Widgets Ely”, “Blue Widgets Cambridge” etc
I proposed they at least “spun” the body copy on these pages. This approach gives you 100s or 1000s of semi-unique pieces of content for little more work than writing one.
I’ve tested this technique on a “madlib” site with 5 million virtual “pages” and whilst Google gobbled them up for a while, it de-indexed most. Interestingly, though, it kept in the index hundreds of pages unique only due to their spun copy. I believe therefore that if used sensitively, keeping in mind human readability and given sufficient options for the number of unique documents required, it still works.
To “fix” a page so that the same random options are used every time when that page is visited, use this near the top of the page:
<?php
mt_srand(crc32($_SERVER['REQUEST_URI'])));
?>
Here’s the function:
<?php
function Spin($txt){
$test = preg_match_all("#\{(.*?)\}#", $txt, $out);
if (!$test) return $txt;
$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, $txt);
}
?>
You use it like this:
<?php
$text = "The {quick|slow|reasonably paced} {brown|green|blue|pink} {fox|goat|rat|camel}
{jumped|walked|hopped} {over|past|under} the {lazy|tired|boring} {dog|cat|stoat}";
$count = 0;
while ($count++ < 100){
echo Spin($text);
echo "<br />";
}
?>
That’s it. Simple effective article spinning for free.
By the way, I’ve seen better and more efficient versions of this - I’m not pretending its the be-all and end-all, but it does the job.
What do you think of this technique? Have you tried it? Please share your findings!
Tags: article spinning · google · php · seo · unique content32 Comments

[...] function to generate contextually similar, different, content. The original concept is here, but I have enhanced it a bit to better suit my [...]
Hi Alex,
Just started my own blog (last Fri - so it’s a bit sparse / unfinished as yet!) and have added a post about this topic too. Hopefully you are happy with this (http://www.paul-norman.co.uk/2009/06/spin-text-for-seo/) and may find the alterations useful in future.
Once again, great concept, thanks!
useful. You still need the jet spinner syntax though. the best way to get that is automatically, at autojetspinner.com - paste in your text, click a button, and bang - The {quick|fast|swift} {brown|russet|red} fox {jumped|leaped|vaulted} over the…
Cool bit of php that. It could be used in all kinds of apps in various ways. Will that code only spin one level deep though? What would need adding to be able to spin two levels deep?
Thank’s a lot guy !
Hi Alex,
How would you modify your script to allow for nested spins ( such as
{test | try { this | that }}? That would be great to have.Hi Alex,
Hope you are well and that you are gearing up for a fun new year! Just a quick one on this topic - someone asked me yesterday for a version of this code that allowed nested spin blocks, so I’ve added a second function that can do this on my blog post on the topic (http://www.paul-norman.co.uk/2009/06/spin-text-for-seo/) the code is a rush job, but it should do the trick…
Thanks fo this. Just about saved my bacon. If you are struggling with this code and the using the URL as a seed and getting an error then try this:
srand(crc32($_SERVER['REQUEST_URI']));
Hope that helps. Paul Norman’s site is down at the moment. I wanted to check his solution as well. Lots of uses for this
YA!
This is just a long shot but I don’t suppose anyone knows if there is an auto - synonym replacement solution to auto spin existing content on the fly? Would need a DB of synonyms I would guess.
i bought a php article submitter script that doesn’t have a spinning capability. so i thought “what if i could change it so it can do spinning while submitting, just like SENuke, that’d be cool! but how do i do that?”, then this article made it possible for me. THANK YOU SO MUCH!
[...] I don’t have to explain to you the importance of avoiding duplicate content on your sites. There are a lot of PHP content spinners avaiable but I really like this one I found here. [...]
Did you even try the code yourself or just type it into a blog post? It just echos the $text var 100 times, never actually spinning anything lol.
It’s hilarious that people are thanking you when the code doesn’t do anything.
Isn’t it?!
People do thank the author because they’re clever enough to have replaced the original quotes of the article by real quotes in this line : $choices = explode(”|”, $out[1][$id]);
Thanks alex !
Thanks for the info. But I have an question about this.
How to make it work for blogspot? Is it possible for blogspot blog?
nope, blogspot does not allow you to run custom code. Sorry. Better and far more secure to host your own blog
Thanks so much for that spinner, i’ve been looking for a good spinning program and couldn’t find anything suitable for my needs. I like your very simple piece of code and will start from it. I will let you know when i add some functions and will post the php code. Cheers!
Thank you very much Alex. I like your script.
Thanks
[...] auf dem blog von Paul Norman (link) zu finden, wobei sein script auf einem script von Alex Poole (link) basiert. Wie das script in aktion aussieht, könnt Ihr hier sehen: php artikelspinner. Den [...]
This gives me a good start on what I was after. I need to add nested spinning and tie it to a form with a preview, but I think this code is what I needed. Thanks.
Cheers. Check out Paul’s evolution of the script for nested spinning:
http://www.paul-norman.co.uk/2009/06/spin-text-for-seo/
Great script! On a side note, would anyone have a php script that could compare 2 articles to determine uniqueness?
Just updated my version of this as I had need for a better nested version. Hopefully it’ll help someone.
http://www.paul-norman.co.uk/2010/09/php-spinner-updated-spin-articles-for-seo/
Hey,
you have an extra ) in the the srand
I can’t get this to work. It prints the same line 100 times
without sipinning anything.
It just prints all the $text words with | shown between them 100
time.
anyone ?
Thanks for the advice. I’ve been trying to use wordpress but some of my sites are simple php because they give me the most seo control. Particularly for a website with only about 25-30 pages of content, i feel like its good to have a strategy to show some updating automatically. I think the only thing i cant seem to find though is a way to spin the content with a time parameter. For example, spin the article once over 36 hours.
Can someone please post or suggest how to do preserve punctuation, symbols (.,;:!?@#$%) and formating (new line, tabs, etc)?
Can someone please post a solution to keep quotes (single and double) from being escaped by backslash, as in \”?
Also, newlines aren’t currently preserved unless there are characters before the newline (if the newline is at the beginning like this {
It won’t print this line on a new line.
Also, it would be nice to accept single {,} since other programs use that syntax.
I think the best thing to do if a user wants to preserve {’s in the text is to require the user to escape the {’s with \{ himself
Unfortunately, this wont be able to do multi level spinning. Ive been looking for such a software for a longe time and tried to code it myself but in the end I will stick with a commercial solution.
Bad thing is, I am from Germany and The Best Spinner did not convince me (it might be great for the englisch language - but not for german…). I think I will give this one http://www.myseosolution.de/seo-tools/article-wizard/ a try. The video looks promising.
Hey Alex,
Thanks for this snippet. It works like a dream.
You’re a gem
Thank you for sharing this code. I was searching for something like this for some time up to now. The ideal solution would be for the code to be able to spin nested brackets as well (I got some texts with bracket nested even to 5 level), but for the simple pages this works good enough though. Greetings.
It is in fact truly incredible how many people ignore (or don’t pay extra attention absolutely) to Yahoo’s Webmaster Pointers