Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $json = '[{"name":"Juar","Sex":"Male","ID":"1100"},{"name":"Maria","Sex":"Female","ID":"2513"},{"name":"Pedro","Sex":"Male","ID":"2211"}]';
- $array = json_decode($json,1);
- $ID = "ar";
- $expected = array_filter($array, function ($var) use ($ID) {
- if (strpos($var['name'],$ID) !== false){
- echo $var['name'];
- return true;
- }
- });
- print_r($expected);
- ?>
Add Comment
Please, Sign In to add comment