문제

When I do var_dump, I get the following result:

stdClass::__set_state(array(
    '0' =>
    stdClass::__set_state(array(
        'field' => 'name',
        'value' => 'John Smith',
        'description' => 'User full name',
    ))
))

I need the field, value & description in separate string vars.
How do I do this?

I tried:

$field = $obj->field;
$field = $obj->0->field;
$field = $obj->'0'->field;
$field = $obj[0]->field;
$field = $obj['0']->field;

Nothing works!?

Thanks

도움이 되었습니까?

해결책

You can use the curly brace syntax to traverse the object, like so:

$obj->{'0'}->field;
$obj->{'0'}->value
$obj->{'0'}->description
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top