1

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?

gsiradze
  • 4,583
  • 15
  • 64
  • 111

1 Answers1

2

Try the following instead:

foreach ($xmlData->{'sub-up'}->result as $res) {

In your code - is evaluating as minus.

mega6382
  • 9,211
  • 17
  • 48
  • 69