0

Maybe a trivial Problem - but im stuck. I have an Array, printed out with print_r

Array ( [Code] => 200 [Content] => Array ( [0] => Array ( [BelegID] => XXXX [BelegDatum] => 1453330800 [Lager] => ABCLAGER [Transporteur] => 0 ) ) )

When i try to access the Array via

if($auftrag['Code'] == "200"){DO SOMETHING}

I get the error

Warning: Illegal string offset 'Code' in

Can someone enlight me please?

Cheers

6
  • $auftrag must be a string and not an array. Commented Feb 5, 2016 at 15:33
  • maybe a typo in array definition? double-check. Commented Feb 5, 2016 at 15:40
  • How can i Change that? That it is an array Commented Feb 5, 2016 at 15:41
  • No, if you have this error. check -it via print_r precisely before if loop, pasting $auftrag from the if. I think a typo or a different scope variable. (Edit: no different scope. It's a string). Commented Feb 5, 2016 at 15:45
  • Somewhere before that line you may have reassigned a string to $auftrag. Commented Feb 5, 2016 at 16:05

1 Answer 1

1

I found my error. It was human working overtime mistake.

I was only doing print_r the Array - so it printed out properly. But i wasn t saving the result of json decode to $auftrag.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.