Also ich bin mit curl einige JSON von einer API zurückzukehren und ich bin mit json_decode($result,true);
foreach assoziatives Array Looping durch
ich es geschafft haben, die title
zugreifen, aber ich muss durch die gesamte Array-Schleife und Ausgang die title
, url
, location
und picture
.
Ich bin ein foreach
tun alles, um den Inhalt zu drucken:
<?php
foreach ($json as $value) {
echo "<pre>";
print_r($json);
echo $json['data'][2]['title'];
}
?>
Welche Blöcke mir seine, wie greife ich auf jedes Element.
Array
(
[paging] => Array
(
[total_items] => 33
[current_page] => 1
[total_pages] => 3
)
[data] => Array
(
[0] => Array
(
[id] => 776583
[title] => NAME
[url] =>URL
[status] => open
[current_status] => open
[location] => a, a
[programmes] => Array
(
[id] => 2
[short_name] => SHORT NAME
)
[applications_count] => 5
[is_favourited] =>
[branch] => Array
(
[id] => 319532
[name] => International SOS - 1
[organisation_id] => 318911
[profile_photo_url] => URL
[url] => URL
)
[views] => 248
[duration_min] => 22
[duration_max] => 24
[applications_close_date] => 2016-09-06T00:00:00.000Z
[earliest_start_date] => 2016-10-01T00:00:00.000Z
[latest_end_date] => 2017-04-01T00:00:00.000Z
[profile_photo_urls] => Array
(
[original] => PIC URL
[medium] => PIC URL
[thumb] => PIC URL
)
[cover_photo_urls] => PNG IMG
[created_at] => 2016-08-30T03:24:41Z
[updated_at] => 2016-08-30T15:36:02Z
)
[1] => Array
(
[id] => 774984
[title] => NAME
[url] => URL
[status] => open
[current_status] => open
[location] => Bonn, Germany
[programmes] => Array
(
[id] => 2
[short_name] => NAME
)
[applications_count] => 128
[is_favourited] =>
[branch] => Array
(
[id] => 287321
[name] => Deutsche Post DHL Group
[organisation_id] => 286836
[profile_photo_url] => PHOTO
[url] => URL
)
[views] => 1331
[duration_min] => 48
[duration_max] => 48
[applications_close_date] => 2016-09-04T00:00:00.000Z
[earliest_start_date] => 2016-10-01T00:00:00.000Z
[latest_end_date] => 2017-10-01T00:00:00.000Z
[profile_photo_urls] => Array
(
[original] => PIC
[medium] => PIC
[thumb] => PIC
)
[cover_photo_urls] => PIC
[created_at] => 2016-08-23T19:47:04Z
[updated_at] => 2016-08-24T06:35:58Z
)
'foreach ($ json ['data'] als $ item) echo $ item ['title'], $ item ['url'];' – deceze
Also wollen Sie durch Ihre SubArray 'Daten', dann in In der foreach-Schleife greifen Sie einfach auf jede gewünschte Taste zu. – Rizier123
@deceze In Ihrem Beispiel kann ich nicht auf ein Subarray zugreifen, um das Bild zu erhalten – Daniel