PHP Mass Keyword Creator

Author: The Kaptain
31.07.2007

The Kaptain recently ported his Keyword Spinner tool from ColdFusion to PHP to fit in with his new suite of blackhat internet hate tools. This bit of code is used to take a list of keywords and a list of “mixer” words and combine them into unique key phrases. You can also specify the maximum number of words you want in a phrase for another level of control.

For testing purposes the Kaptain created 2 arrays with 7 elements each and told the script to generate 1000 keywords. The script took about 1.5 seconds to return with 961 unique key phrases all containing 4 words or less.

Here is the code and usage will follow:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
<?php
	function GenerateKeywords($keywords,$mixerwords,$numtogen,$maxwordsinkey){
		$pos = 0;
		$numToMix = 1;
		$counter = 1;
		$newKeys = array();
 
		for($i=0; $i <= $numtogen; $i++){
			$useKey = $keywords[$pos];
			$mixedKey = MixKey($numToMix,$mixerwords,$useKey);
				if(!in_array($mixedKey,$newKeys)){
					$newKeys[] = $mixedKey;
					$counter++;
				}
				if($pos == count($keywords)){
					$pos = 0;
 
					if($numToMix < $maxwordsinkey){
						$numToMix++;
					}
			}
			$pos++;
		}
		return $newKeys;
	}
 
	function MixKey($mixers,$mixwords,$keytomix){		
			for($i=1; $i<=$mixers; $i++){
				$append = rand(0,1);
				$tmp = rand(0,count($mixwords));
				if( $i == 1){
					$returnThis = $keytomix;
				}
				$word = $mixwords[$tmp];
					if($append == 1 && strpos($returnThis,$word) === false){
						$returnThis = $returnThis ." ". $mixwords[$tmp];
					}else if(strpos($returnThis,$word) === false ){
						$returnThis = $mixwords[$tmp] ." ". $returnThis;
					}
			}
			//echo $returnThis."<br>";
			return trim($returnThis);		
	}
 
?>

Simply include the file, setup some arrays of keywords and mix-in words from whatever sources you see fit, decide how many key phrases you want to create, and the maximum number of words in a phrase. Note: each keyword in your keyword array no matter how many words it contains, will count as one keyword to the script. So, if your keyword is “tasty pies” and you tell the script to create a phrase that is a maximum of 4 words - you will get “tasty pies” plus 3 additional words thus yielding a 5 word phrase. So be mindful of that when selecting your starter keywords and maximum word count.

Usage:

1
2
3
4
5
6
7
8
9
10
<?php
 
include 'keywordSpinner.php';
 
	$mix = array("big","smelly","red","orange","expensive","tasty","pies");
	$keys = array("sunglasses","shoes","hats","pants","cars","trucks","toys");
 
		$newKeys = GenerateKeywords($keys,$mix,1000,4);
		print_r($newKeys);
?>

Obviously in this example the code was saved as “keywordSpinner.php” which is the file that is included.

Click here to download the keywordSpinner.php file

affiliate forum


One Response to “PHP Mass Keyword Creator”

  1. Words for the Keyword Creator | Kaptain Krayola Pie Quest - pie 2.0 Says:

    […] PHP Mass Keyword Creator […]

Leave a Reply


Clicky Web Analytics
taky