<?php
$json = '[{"name":"Juan","Sex":"Male","ID":"1100"},{"name":"Maria","Sex":"Female","ID":"2513"},{"name":"Pedro","Sex":"Male","ID":"2211"}]';
$array = json_decode($json,1);
$sex = ‘Male’
$expected = array_filter($array, function ($var) use ($sex) {
return ($var['sex'] == $sex);
});
print_r($expected);
?>
- Output for 8.1.0 - 8.1.30, 8.2.0 - 8.2.25, 8.3.0 - 8.3.13
- Parse error: syntax error, unexpected variable "$expected" in /in/438XP on line 5
Process exited with code 255.
preferences:
148.79 ms | 1435 KiB | 7 Q