patrich Posted October 5, 2009 Share Posted October 5, 2009 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 More sharing options...
redarrow Posted October 5, 2009 Share Posted October 5, 2009 where the random keyword that going to be used cumming from a list? a web site? where please... Link to comment https://forums.phpfreaks.com/topic/176501-adding-random-keywords-to-this-snippet/#findComment-930374 Share on other sites More sharing options...
patrich Posted October 5, 2009 Author Share Posted October 5, 2009 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? Link to comment https://forums.phpfreaks.com/topic/176501-adding-random-keywords-to-this-snippet/#findComment-930376 Share on other sites More sharing options...
redarrow Posted October 5, 2009 Share Posted October 5, 2009 shuffle every think but show 1 number/letter. <?php $a=array(1,2,3,4,5,6,7,8,9); echo array_rand($a); ?> shuffle ever think in the array and show. <?php $b=array(1,2,3,4,5,6,7,8,9); shuffle($b); $c=implode(' ',$b); echo $c; ?> Link to comment https://forums.phpfreaks.com/topic/176501-adding-random-keywords-to-this-snippet/#findComment-930378 Share on other sites More sharing options...
patrich Posted October 5, 2009 Author Share Posted October 5, 2009 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? Link to comment https://forums.phpfreaks.com/topic/176501-adding-random-keywords-to-this-snippet/#findComment-930417 Share on other sites More sharing options...
redarrow Posted October 5, 2009 Share Posted October 5, 2009 <?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; } ?> Link to comment https://forums.phpfreaks.com/topic/176501-adding-random-keywords-to-this-snippet/#findComment-930418 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.