3v4l.org

run code in 300+ PHP versions simultaneously
<?php $json = <<<JSON [ { "foo": "bar", "subject": "some subject" }, { "qux": "baz", "subject": "some other subject" } ] JSON; $data = json_decode($json, true); // true is important otherwise will get a stdObject - not an array $subjects = array(); foreach ($data as $a) { $subjects[] = $a['subject']; } var_dump($subjects);

preferences:
44.79 ms | 402 KiB | 5 Q