homepage Welcome to WebmasterWorld Guest from 54.145.183.126
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

    
getting info from array and subarray
defanjos

WebmasterWorld Senior Member 10+ Year Member



 
Msg#: 4642840 posted 10:57 pm on Feb 5, 2014 (gmt 0)

I have a array called $response. If I print it with "print_r ($response);", I get:


Array (
[0] => Array ( [id] => 96865 [propertyName] => [property] => Array ( [myID] => 1234 [listingID] => 1340784 ) [receiveUpdates] => y [created] => 2014-02-04 23:46:12 [lastEdited] => 0000-00-00 00:00:00 )
[1] => Array ( [id] => 96868 [propertyName] => [property] => Array ( [myID] => 1234 [listingID] => 1351414 ) [receiveUpdates] => y [created] => 2014-02-04 23:47:39 [lastEdited] => 0000-00-00 00:00:00 )
[2] => Array ( [id] => 96869 [propertyName] => [property] => Array ( [myID] => 1234 [listingID] => 1347542 ) [receiveUpdates] => y [created] => 2014-02-04 23:48:15 [lastEdited] => 0000-00-00 00:00:00 )
)


I am trying to get some info out of it with a loop, but it only gets out $value[id], not $value[myID] and $value[listingID]
How can I do that?
I know the problem is an array within another, but I can't figure it out.



foreach($response as $key=>$value) {
echo $value[id] . " - " . $value[myID] . " - " . $value[listingID] . "<br>";
}


Thanks in advance.

 

penders

WebmasterWorld Senior Member penders us a WebmasterWorld Top Contributor of All Time 5+ Year Member Top Contributors Of The Month



 
Msg#: 4642840 posted 2:02 am on Feb 6, 2014 (gmt 0)

It looks like you have a nested array, so....

$value['property']['myID']

Also, I assume 'id', 'myID' etc. are strings, not constants?

defanjos

WebmasterWorld Senior Member 10+ Year Member



 
Msg#: 4642840 posted 2:32 am on Feb 6, 2014 (gmt 0)

Great, that worked. Thanks.

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved