Note that there are some explanatory texts on larger screens.

plurals
  1. POFilter a php array from JSON with PHP
    text
    copied!<p>I am pulling data from a json and decoding it via json_decode. Here is the code I am using:</p> <pre><code>$jsonurl = "http://ebird.org/ws1.1/data/obs/geo/recent?lng=-76.51&amp;lat=42.46&amp;dist=2&amp;back=1&amp;maxResults=500&amp;locale=en_US&amp;fmt=json&amp;includeProvisional=true"; $json = file_get_contents($jsonurl); $json_output = json_decode($json); </code></pre> <p>This gives results the results in the format:</p> <pre><code>Array ( [0] =&gt; stdClass Object ( [comName] =&gt; House Sparrow [howMany] =&gt; 2 [lat] =&gt; 42.4613266 [lng] =&gt; -76.5059255 [locID] =&gt; L99381 [locName] =&gt; Stewart Park [locationPrivate] =&gt; [obsDt] =&gt; 2012-02-28 08:26 [obsReviewed] =&gt; [obsValid] =&gt; 1 [sciName] =&gt; Passer domesticus ) [1] =&gt; stdClass Object ( [comName] =&gt; Common Merganser [howMany] =&gt; 7 [lat] =&gt; 42.4613266 [lng] =&gt; -76.5059255 [locID] =&gt; L99381 [locName] =&gt; Stewart Park [locationPrivate] =&gt; [obsDt] =&gt; 2012-02-28 08:26 [obsReviewed] =&gt; [obsValid] =&gt; 1 [sciName] =&gt; Mergus merganser ) [2] =&gt; stdClass Object ( [comName] =&gt; Herring Gull [howMany] =&gt; 100 [lat] =&gt; 42.4613266 [lng] =&gt; -76.5059255 [locID] =&gt; L99381 [locName] =&gt; Stewart Park [locationPrivate] =&gt; [obsDt] =&gt; 2012-02-28 08:26 [obsReviewed] =&gt; [obsValid] =&gt; 1 [sciName] =&gt; Larus argentatus ) ) </code></pre> <p>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"?</p> <p>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!</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload