Jump to content

Adding Random Keywords to this Snippet?


patrich

Recommended Posts

Hi everyone, this is my first post here!

 

I have a little php script that pulls serp data and displays it in my website. It searches MSN for a keyword that I enter and then gets me "x" listings. I would like the script to use a random keyword from a .txt file to use for the search query?

 

I have tried file_get_contents and several other functions without any luck. I also tried to use a simple random quote php script to no avail. Any ideas?

 

$keyword = $paramsA{'my_keyword'};
$keyword = eregi_replace("\.s*html*$","",$keyword);
$keyword = eregi_replace("\-|\_|\.|%20| ","+",$keyword);
$keyword_phrase_array = preg_split('/\+/',$keyword);

$limit = $paramsA{'limit'};if (!$limit) { $limit = 0; }

 

I would like to replace 'my_keyword' in the snippet above with a random keyword/search string but can't seem to get it to work any help would be appreciated.

 

Thanks

Link to comment
https://forums.phpfreaks.com/topic/176501-adding-random-keywords-to-this-snippet/
Share on other sites

I would like the random keywords to come from a simple text file from the same directory.

 

Another option, if possible, would be to just randomize the keywords within this script itself, ie. keyword1, keyword2 etc.

 

Any ideas on how to accomplish this?

Thanks for the code!  Not sure where I should put it though? I tried adding it like this:

 

$keyword = $paramsA{'<?php
$a=array(keyword1,keyword2,keyword3);

echo array_rand($a);

?>'};
$keyword = eregi_replace("\.s*html*$","",$keyword);
$keyword = eregi_replace("\-|\_|\.|%20| ","+",$keyword);
$keyword_phrase_array = preg_split('/\+/',$keyword);

$limit = $paramsA{'limit'};if (!$limit) { $limit = 0; }

 

Didn't work though, should I be adding it differently?

 

<?php
$keyword = $paramsA{'<?php
$a=array(keyword1,keyword2,keyword3);

echo array_rand($a);

?>'};
$keyword = eregi_replace("\.s*html*$","",$a);
$keyword = eregi_replace("\-|\_|\.|%20| ","+",$a);
$keyword_phrase_array = preg_split('/\+/',$a);

$limit = $paramsA{'limit'};if (!$limit) { $limit = 0; }
?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.