)
etc etc .
[9] => Array(
[BIZNAME] => Kielty Computers
)
[10] => Array(
[DESC] => laptop
[MAKE] => Toshiba
[MODEL] => Satellite
[PRICE] => 1699
)
)
Now that we have an array of items and their attributes from all of the requested shops
($shoparray[]), and a list of criteria to compare those attributes against ($mcrits[]), we
call the grep() function, which takes these two arrays as parameters. grep() invokes
test_line() on each of the items in of $shopsarray[] (each item in turn being an associative
array). If an item passes test_line(), the function spit() prints it to the screen. grep() also
keeps track of the title of the current business, without which there would be a long list of
products with no indication as to which shop they come from.
test_line() tests each of the key/value pairs of $mcrit[] (query criteria) against each of the
key/value pairs in the item array (referred to as line[] within the function). A $yescount
variable is incremented each time one of the query criteria matches one of the item
attributes and the function only returns true if, at the end, $yescount is equal to the
number of search criteria (and thus, by definition, the item has matched all of the
criteria).
42