Created
December 29, 2015 19:25
-
-
Save maxkostinevich/0f3fd7530d830ce2b142 to your computer and use it in GitHub Desktop.
Search in JSON-Array
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function search_json($obj, $field, $value) { | |
foreach($obj as $item) { | |
foreach($item as $child) { | |
if(isset($child[$field]) && ($child[$field] == $value)) { | |
return $child; | |
} | |
} | |
} | |
return null; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment