User inputs data into form (e.g. four animals: "dog, buffalo, bird, and ant") and submits. Then, cURL script scrapes a website and uses preg_match_all to put the results in an array. When the array is print_r'd, here's the result:
$matches = array(
"dog" => "four legs",
"ant" => "six legs
);
The problem is it's missing the "bird" input and the "buffalo". The reason is the Curlded website has no data on buffalos or birds! Although the website has data on most animals, some animals are missing (e.g. the "bird" from the example above) and therefore no "bird data" gets preg_matched.
Is there an elegant way of having the desired resultant array list those non-existant animals as "not found" like this:
array(
"dog" => "four legs",
"ant" => "six legs",
"bird" => "not found",
"buffalo" => "not found"
);
Note: the way I'm doing it now looping thru' the user inputted animals and using strstr to see if those animals are in the curled result; if not, those are placed in an array (e.g. "bird"=>"not found") and then array_merged with the array of animals that successfully were preg_match_all'd.
My way feels "un-elegant" and feels like there must be a more svelte, sleek, 'cool' way to do this :-)