I have 4 functions for searching through an XML feed. Each search function is on its own separate php page. Each page is then called as an include in the main page to run its particular search function. These functions only difference is the variable that is passed to them to search for. E.g.
What I would like to do is have one function that runs the function for each word out putting the results each time — using a loop I guess. I think I need to start by storing the search terms as an array but from here Im struggling.
Would someone be able to shine some light on this?
That’s great. I have a background in flash actionscript and thought you might be able to pass values to functions like that.
I thought the search function would be to large to post here. It uses simplexml_load_string to search though an XML feed for ‘posts’ with a certain term. When it finds one it then write it in html form to a new file.
Would this sort of thing work / be effective?
function mysearchfuction() {
$num = func_num_args(); //
//echo $num;
$total = 0;
for( $i = 0; $i < $num; ++$i ) {
echo "<br>do search using ";
echo func_get_arg($i);
/// do search code here
}
}
$result = mysearchfuction('ham', 'eggs', 'cheese'); // call function and pass terms
I am thinking aloud here but if you imagine I have a source XML feed. From that feed I want to search for certain keywords. When I find a match I want to write this to a new XML file. Effectively ending up with a XML file for each keyword.
I would like to repeat this process via a cron so that when the source XML feed updates the new items are added to my created XML files - like creating an archive.