Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.php > #6770
| Date | 2012-08-11 11:05 +0200 |
|---|---|
| From | Luuk <luuk@invalid.lan> |
| Newsgroups | comp.lang.php |
| Subject | Re: json_decode problem |
| References | <slrnk2avb8.be8.houghi@penne.houghi> <slrnk2c7dk.4f7.houghi@penne.houghi> |
| Message-ID | <5rjhf9-7au.ln1@luuk.invalid.lan> (permalink) |
On 11-08-2012 10:54, houghi wrote:
> 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
>
use isset() to check if a quote of stage exists....
(see post from Gregor)
Back to comp.lang.php | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
json_decode problem houghi <houghi@houghi.org.invalid> - 2012-08-10 23:30 +0200
Re: json_decode problem Gregor Kofler <usenet@gregorkofler.com> - 2012-08-11 10:43 +0200
Re: json_decode problem houghi <houghi@houghi.org.invalid> - 2012-08-11 13:09 +0200
Re: json_decode problem Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2012-08-12 13:44 +0200
Re: json_decode problem Luuk <luuk@invalid.lan> - 2012-08-12 15:28 +0200
Re: json_decode problem Luuk <luuk@invalid.lan> - 2012-08-12 15:32 +0200
Re: json_decode problem Gregor Kofler <usenet@gregorkofler.com> - 2012-08-12 18:12 +0200
Re: json_decode problem Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2012-08-12 23:30 +0200
Re: json_decode problem Curtis Dyer <dyer85@gmail.com> - 2012-08-20 10:41 +0000
Re: json_decode problem Jerry Stuckle <jstucklex@attglobal.net> - 2012-08-20 07:30 -0400
Re: json_decode problem Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2012-08-20 16:45 +0200
Re: json_decode problem houghi <houghi@houghi.org.invalid> - 2012-08-11 10:54 +0200
Re: json_decode problem Luuk <luuk@invalid.lan> - 2012-08-11 11:05 +0200
Re: json_decode problem houghi <houghi@houghi.org.invalid> - 2012-08-11 13:11 +0200
csiph-web