FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » json_decode problem
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
Re: json_decode problem [message #178846 is a reply to message #178844] Sun, 12 August 2012 13:32 Go to previous messageGo to previous message
Luuk is currently offline  Luuk
Messages: 329
Registered: September 2010
Karma:
Senior Member
On 12-08-2012 13:44, Thomas 'PointedEars' Lahn wrote:
> Gregor Kofler wrote:
>
>> Am 2012-08-10 23:30, houghi meinte:
>>> <?php
>>> $json = file_get_contents("imdb.json");
>>> $result = json_decode($json);
>>> foreach($result->data->quotes as $p)
>>> {
>>> $qconst = $p->qconst;
>>> echo "quotenumber = $qconst<br>";
>>> //Some foreach here?
>>> //No idea what to put here
>>> }
>>> ?>
>>>
>>> I do get the above part right, but I am lost on how to do the rest. I
>>> assume I must do some other foreach.
>>
>> foreach($p->lines as $l) {
>> echo $l->stage;
>>
>> if(isset($l->quote)) {
>> echo $l->quote;
>> }
>>
>> if(isset($l->chars) {
>> foreach($l->chars as $c) {
>> echo $c->char;
>> echo $c->nconst;
>> }
>> }
>>
>> ....
>> }
>
> FYI: isset() should not be used with properties, because it fails with
> protected or private properties that have getters:
>
.....
.....
>


maybe you should not use
var_dump(isset(...));

it's pretty useless because:
isset() will always return 'true' of 'false'
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: PEAR Auth package woes
Next Topic: redirect on zend
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Mon Nov 25 03:47:40 GMT 2024

Total time taken to generate the page: 0.04911 seconds