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 #178839 is a reply to message #178832] Sat, 11 August 2012 08:54 Go to previous messageGo to previous message
houghi is currently offline  houghi
Messages: 45
Registered: September 2011
Karma:
Member
houghi wrote:
> I am stuck with json_decode. I have a json file
> http://houghi.org/Fun/imdb.json
> <?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
> }
> ?>

As always one finds the answer shortly after posting, regardless how
many hours you were looking for the solution. (30-40 over a weeks
period)

The file I use is http://houghi.org/Fun/imdb.json

<?php
$json = file_get_contents("imdb.json");
$result = json_decode($json);
foreach($result->data->quotes as $p)
{
$qconst = $p->qconst;
print "quote=$qconst<br>\n";
$qconst = $p->lines;
foreach ($qconst as $q)
{
$quote = $q->quote;
$stage = $q->stage;
if ($stage != "") { $stage = '<i>['.$stage.']</i> ';}
$chars = $q->chars;
foreach ($q->chars as $r)
{
$char = $r->char." ";
$nconst = $r->nconst." ";
}
print $char.$nconst.$stage.$quote."<br>\n";
}
print "<hr>\n";
}
?>

It seems obvious now. Anybody an idea on how to improve it? I myself
will re-write the output to put the data it in a database (for personal
use).

houghi
--
You can have my keyboard ...
if you can pry it from my dead, cold, stiff fingers
[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: Sun Dec 01 01:31:39 GMT 2024

Total time taken to generate the page: 0.03212 seconds