3v4l.org

run code in 300+ PHP versions simultaneously
<?php $json = '[ { "CarID": "f11gh126-dee8-46ef-9665-69119c354575", "CarReg": "ABCD" }, { "CarID": "e258f6d4-4503-5d7e-b25c-1fb9767061e2", "CarReg": "DEFG" } ]'; $arr = json_decode($json, true); $carId = array_filter($arr, function($item){ return $item['CarReg'] == 'ABCD'; })[0]['CarID']; echo $carId;

preferences:
26.29 ms | 405 KiB | 5 Q