3v4l.org

run code in 300+ PHP versions simultaneously
<?php $json = '[{"id": 10, "title": "book"},{"id": 24,"title": "cars"},{"id": 52, "title": "houses"}]'; $array = json_decode($json,1); $title = 'cars'; $result = array_filter($array, function ($element) use ($title) { return ($element['title'] == $title); }); echo array_column($result,'id')[0]; ?>

preferences:
175.95 ms | 406 KiB | 5 Q