please help me for read a parameter from array in php: when use from print_r for view array , result is:
getUserServicesResponse Object (
[getUserServiceResponse] =>
[return] => stdClass Object (
[isactive] => 1
[lastQnum] => 0
[qnum] => 5
[score] => 0
[service] => stdClass Object (
[countActive] => 73657
[countAll] => 199784
[lastTime] => 2015-12-01T08:38:06.065+03:30
[maxScore] => 33000
[minScore] => 0
[minregdate] => 2014-08-05T15:27:12+04:30
[serviceName] => game
[topNumber] => 09121153321
)
[serviceID] => 12946
)
)
i want print serviceName value from array that is game or print score from array that is 0 thanks
To access a parameter from php object (stdClass or normal)
you need object name
with ->
and the attribute name
which you want to access,
in your case there are many stdClass objects one after another so the correct ways is,
echo $getUserServicesResponse->return->service->serviceName;
output:
game
FYI
the structure for which i have generated the output
stdClass Object
(
[return] => stdClass Object
(
[isactive] => Harry Potter and the Prisoner of Azkaban
[service] => stdClass Object
(
[serviceName] => game
)
)
)
Try this
$object->getUserServiceResponse->service->serviceName;