- var_dump: documentation ( source)
- json_decode: documentation ( source)
<?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);