I have tags like this in my xml
<sub-up ...>...</sub-up>
and when I do this
$xmlData = simplexml_load_string($decodeData);
foreach ($xmlData->sub-up->result as $res) {
print_r($res);
}
I'm getting an error:
"Parse error: syntax error, unexpected '->' (T_OBJECT_OPERATOR)"
But when I replace this tag to subup
everything works well. What can I do? I can't replace all -
or characters like this
Is there any solution?
Try the following instead:
foreach ($xmlData->{'sub-up'}->result as $res) {
In your code -
is evaluating as minus.