Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.php > #6767
| From | Gregor Kofler <usenet@gregorkofler.com> |
|---|---|
| Newsgroups | comp.lang.php |
| Subject | Re: json_decode problem |
| Date | 2012-08-11 10:43 +0200 |
| Organization | A noiseless patient Spider |
| Message-ID | <k055v2$62k$1@dont-email.me> (permalink) |
| References | <slrnk2avb8.be8.houghi@penne.houghi> |
Am 2012-08-10 23:30, houghi meinte:
> I am stuck with json_decode. I have a json file
> http://houghi.org/Fun/imdb.json
> I want it to look like http://www.imdb.com/title/tt0382932/quotes
> Well, not completely. Just pure text.
>
> e.g. the second one should be something like
> quotenumber = qt0465193
> Remy/nm0652663 Stage=observing what Emile is eating Quote=What are you eating?
> Emile/nm0812307 Stage=pause Quote=I don't really know. I think it was some sort of wrapper once.
> Remy/nm0652663 Quote=What? No! You're in Paris now, baby! My town! No brother of mine eats rejecta-menta in my town!
>
> The code I have is extremely basic. I have been looking at many
> websites, but am unable to figure it out what I must put in it to make
> it work:
>
> <?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;
}
}
....
}
> No idea where to start, even after many days
> and websites.
And never heard of var_dump()?
Gregor
--
http://vxweb.net
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