Hi I am trying to get “fulltext” values from this json file on this Link
I am getting only top of the array how can I get all values from all arrays even the nested ones
$json_output = json_decode($json, true);
var_dump($json_output);
foreach($json_output['results'] as $item) {
echo '<br/>'. $item['fulltext'];
The linked item is not json, it’s array notation.
Personally, I’d use a preg_match_all, but as you want to loop:
foreach($output['results'] AS $result) {
foreach($result['printouts']['Covers topic'] AS $topic) {
echo "<br />".$topic['fulltext'];
}
echo "<br />".$result['fulltext'];
}
wyamout
December 11, 2013, 6:43pm
4
Hi StarLion
I need to ask one more question for this:
is it possible to make $result[‘fulltext’] as links that open a new window displaying the $topic[‘fulltext’] of its specific array?
thanks
StarLion:
The linked item is not json, it’s array notation.
Personally, I’d use a preg_match_all, but as you want to loop:
foreach($output['results'] AS $result) {
foreach($result['printouts']['Covers topic'] AS $topic) {
echo "<br />".$topic['fulltext'];
}
echo "<br />".$result['fulltext'];
}
Theoretically, sure.
Either have the new window call it’s own fetch of the array and isolate the desired result, or pass the fulltext on to the page as a GET (not really recommended, but it’d work at least).
wyamout
December 11, 2013, 7:02pm
6
Any example you can show me?
StarLion:
Theoretically, sure.
Either have the new window call it’s own fetch of the array and isolate the desired result, or pass the fulltext on to the page as a GET (not really recommended, but it’d work at least).
Have the new window walk the array (foreach), looking for a result (or a covers-topic) that has the name you’re looking for (which would be passed to it via a $_GET variable such as newwindow.php?name=SCI1021 ), and access that element’s fulltext entry.