Sure. First off, use the second param of json_decode
so you're actually working with an array and not an object. Then filter the array with the items you want (where registration_id
is set) and get the keys.
$newData=json_decode($data, true);
$filteredResults = array_filter($newData['results'], function($item) {
return isset($item['registration_id']);
});
print_r(array_keys($filteredResults));
Working example: http://3v4l.org/e8doL
Note this code assumes you are using PHP 5.3 or later. If you are on an earlier version, you'll need to define your array_filter
callback function first and pass it in rather than using an anonymous function.