0
 stdClass Object ( [free] => 100% δωρεάν [meetsingles] => Γνωρίστε Singles [searchprofiles] => Προφίλ Αναζήτηση )

I have a JSON array that after decoded 'json_decode' and printed to screen it looks like above - using UTF8 for Greek.

This is how I print it:

$siteLanguages = json_decode($result);
print_r($siteLanguages);

When I try to access one of the values the page displays only until the point of the print and then it stops loading - eg: like half a page will show - comment this out and the whole page shows - below is how I'm trying:

 print $siteLanguages['searchprofiles'];

I can't see why I can't use the associate array like any other.

Is there a trick I'm missing here? Should the decoded json array show 'stdClass Object' when printed?

thx

2
  • json_decode returns an object, not an array. So you should try something like $siteLanguages->searchprofiles; Commented Dec 30, 2011 at 7:09
  • If you'd like to have json_decode return an array, pass true as it's second parameter. Commented Dec 30, 2011 at 7:10

2 Answers 2

2

I think you're dealing with an object, not array

print $siteLanguages -> searchprofiles;
Sign up to request clarification or add additional context in comments.

Comments

1

The right way is this: $siteLanguages = json_decode($result,true); will get an array,your way get an object;

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.