Tell me more ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.
 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

share|improve this question
json_decode returns an object, not an array. So you should try something like $siteLanguages->searchprofiles; – Srisa Dec 30 '11 at 7:09
If you'd like to have json_decode return an array, pass true as it's second parameter. – refp Dec 30 '11 at 7:10

2 Answers

up vote 2 down vote accepted

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

print $siteLanguages -> searchprofiles;
share|improve this answer

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

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.