Get value from JSON object
stdClass Object
(
[form] => stdClass Object
(
[fieldsets] => Array
(
[0] => stdClass Object
(
[fieldset_name] => name_1
[datapoints] => Array
(
开发者_开发技巧 [0] => stdClass Object
(
[dp_id] => 4
)
[1] => stdClass Object
(
[dp_id] => 5
)
)
)
[1] => stdClass Object
(
[fieldset_name] => name_2
[datapoints] => Array
(
[0] => stdClass Object
(
[dp_id] => 1
)
[1] => stdClass Object
(
[dp_id] => 3
)
)
)
)
)
)
Now i want the values of dp_id seperately into two arrays ie.,array(4,5) and array(1,3)
foreach($object->form->fieldsets as $fieldset) {
$dp_ids = array();
foreach($fieldset->datapoints as $datapoint)
$dp_ids[] = $datapoint->dp_id;
var_dump($dp_ids);
}
try this.
$object->form['fieldsets'][1]->datapoints[1]
精彩评论