Wednesday, February 08, 2006

Unique Articles

Reading about http://www.plrmanna.com/ made me think about the RSSG article script I wrote, and how I could manipulate my articles to make them appear unique. I would want to do this as the article is displayed in the page, and not in a once and done type of way. Since my pages are cached, the article would display the same way for 14 days, and then on the next page load would become unique in a different way.

The first thing I wanted to try to do was to put a block of text in the middle of the article. How would I find the middle? Depending on how the article was formatted (I'll assume 2 BR tags are used between each paragraph) I would count the total number of occurences of the paragraph break, divide by 2, and merge my text there.

The first thing I needed to do was to figure out a way to find the Nth occurance of a string within a larger string. I was able to do that using this function:

function strposnth($haystack, $needle, $nth=1, $insenstive=0) {
if ($insenstive) {
$haystack=strtolower($haystack);
$needle=strtolower($needle);
}
$count=substr_count($haystack,$needle);
if ($count<1> $count) return false;
for($i=0,$pos=0,$len=0;$i<$nth;$i++) { $pos=strpos($haystack,$needle,$pos+$len); if ($i==0) $len=strlen($needle); } return $pos; }

To find the middle of the article, I would do:

$text = file_get_contents($article_path . $file);
$paragraph_count = substr_count($text, "(2 BR TAGS REMOVED FOR BLOGGER)");
$middle = floor($paragraph_count / 2);
$middlepos = strposnth($text,"(2 BR TAGS REMOVED FOR BLOGGER)",$middle);
$start_text = substr($text,0,$middlepos);
$end_text = substr($text,$middlepos);

So that got me the beginning and end of the article. I could then add text in the middle like this:

$middletxt = "(2 BR TAGS REMOVED FOR BLOGGER)This is the paragraph I am adding";
$outtext = $start_text . $middletxt . $end_text;

I know this is pretty easy stuff, but I thought I would post about it. I would like to get together a list of synonyms that can be used on most articles without causing problems. I'll then have my script automatically replace these words in the articles. Adding a header, middle, footer, and replacing the synonyms should make the article appear more unique to the search engines. I am going to sign up for one of the PLR article sites as soon as I get this script working as wanted.

1 comment:

Anonymous said...

Gary,
That is similar to what I had in mind. Its easy to code, I'm not not sure on the best way to develop the synonym lists.