Answer the question
In order to leave comments, you need to log in
How to access a field of a PHP object if the name consists of numbers?
Hello php progers.
I came across such a problem, after parsing the xml string simplexml_load_string I get such an object prntscr.com/56iw04 how to access properties with such names.
Tried like this
$xml->url[0];
$xml->url['0'];
$xml->url->0;
$xml->url->'0';
$xml->url->{'0'};
$xml->url->{0};
Answer the question
In order to leave comments, you need to log in
All the task is solved it is necessary to explicitly cast the types (array)$xml->url[0];
I did not know that in php you can cast to an array)))
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question