I am pulling data from a json and decoding it via json_decode. Here is the code I am using:
$jsonurl = "http://ebird.org/ws1.1/data/obs/geo/recent?lng=-76.51&lat=42.46&dist=2&back=1&maxResults=500&locale=en_US&fmt=json&includeProvisional=true";
$json = file_get_contents($jsonurl);
$json_output = json_decode($json);
This gives results the results in the format:
Array ( [0] => stdClass Object ( [comName] => House Sparrow [howMany] => 2 [lat] => 42.4613266 [lng] => -76.5059255 [locID] => L99381 [locName] => Stewart Park [locationPrivate] => [obsDt] => 2012-02-28 08:26 [obsReviewed] => [obsValid] => 1 [sciName] => Passer domesticus ) [1] => stdClass Object ( [comName] => Common Merganser [howMany] => 7 [lat] => 42.4613266 [lng] => -76.5059255 [locID] => L99381 [locName] => Stewart Park [locationPrivate] => [obsDt] => 2012-02-28 08:26 [obsReviewed] => [obsValid] => 1 [sciName] => Mergus merganser ) [2] => stdClass Object ( [comName] => Herring Gull [howMany] => 100 [lat] => 42.4613266 [lng] => -76.5059255 [locID] => L99381 [locName] => Stewart Park [locationPrivate] => [obsDt] => 2012-02-28 08:26 [obsReviewed] => [obsValid] => 1 [sciName] => Larus argentatus ) )
Now, I have been trying for a few days now to filter based on the comName. How for example could you give an array of only the objects where comName = "House Sparrow"?
I am fairly new to php so if there is a better way to do any of this please let me know. Thanks in advance!