Webmaster Forum

Go Back   Webmaster Forum > Web Development > Coding Forum

Coding Forum Problems with your code? Discuss coding issues, including JavaScript, PHP & MySQL, HTML & CSS, Flash & ActionScript, and more.

Thread Tools Display Modes
Share |
Old 02-25-2018, 09:39 PM
poster poster is offline
Contributing Member
Join Date: 05-01-06
Location: San Francisco, CA
Posts: 126
iTrader: 0 / 0%
Walking through multidimensional json array with PHP

I need to access a large nested multidimensional array in json using PHP

So, in the example below I need to get to the ID at the very bottom, I can do it by using echo $myarray['Data']['Car']['Id']

but how do I access by key, e.g. ['Data'][0]['Id'] and how can I loop through all of the array values, if I am only interested in the Id value??

$myarray =

Array (

[Response] => Success
[Message] => Lorem Ipsum
[URL] => https://www.test.com
[BaseLinkUrl] => https://www.test.com
[Default] =>
Array (
[Desc] => 12345
[Known] => yes )
[Data] =>
Array (
[Car] =>
Array (
[Id] => 98333

Reply With Quote



Old 03-23-2018, 06:43 AM
wmtips's Avatar
wmtips wmtips is offline
Junior Member
Join Date: 01-14-08
Posts: 9
iTrader: 0 / 0%
If you already converted JSON string to an array, you can iterate array items with code similar to this:

PHP Code:
foreach ($myarray['Data'] as $key=>$arr)
$key.' = '.$arr['Id'].'<br />';

Reply With Quote
Go Back   Webmaster Forum > Web Development > Coding Forum


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Shared: inventivehosting.co.uk (25% OFF Recurring) inventive Web Hosting 0 01-05-2018 04:12 PM
Display image based on date using PHP HTMLBasicTutor Coding Forum 2 10-09-2017 01:48 PM
PHP /Magento developer who has a passion for developing complex solutions rjtexas17 Sell Web Services 0 07-12-2017 04:58 AM
Shared: inventivehosting.co.uk (25% OFF Recurring) inventive Web Hosting 0 03-21-2017 05:18 AM

V7N Network
Get exposure! V7N I Love Photography V7N SEO Blog V7N Directory

All times are GMT -7. The time now is 12:17 AM.
Powered by vBulletin
Copyright 2000-2014 Jelsoft Enterprises Limited.
Copyright © 2003 - 2018 VIX-WomensForum LLC