spmckee Posted March 10, 2010 Share Posted March 10, 2010 I am creating a navigation hierarchy out of a multidimensional array and am having a terrible time trying to pull a single array out. Here's the code: <? $L1_array = array( 'Colors & Shapes' => array ( 'Colors' => array ( 'Orange', 'Blue', 'White', 'Red' ), 'Shapes' => array( 'Circle', 'Square', 'Triangle' ), ), 'Animals & People' => array ( 'Animals' => array ( 'Ducks', 'Snails', 'Dogs' => array ( 'Huskies', 'Chows', 'Retrievers' => array ( 'Golden Retriever', 'Chesapeake Bay Retriever', 'Curly-Coated Retriever', 'Flat-Coated Retriever', 'German Water Spaniel', 'Golden Retriever', 'Irish Water Spaniel' ), 'People' => array ( 'Russians', 'Canadians', 'Germans' ), ), ) ?> For instance, how can I pull out and loop through JUST the retrievers array? Any help is greatly appreciated! Thanks Link to comment https://forums.phpfreaks.com/topic/194792-finding-single-array-in-multidimensional/ Share on other sites More sharing options...
mattal999 Posted March 10, 2010 Share Posted March 10, 2010 foreach($L1_array['Animals & People']['Animals']['Dogs']['Retrievers'] as $retriever) { echo $retriever; } Link to comment https://forums.phpfreaks.com/topic/194792-finding-single-array-in-multidimensional/#findComment-1024315 Share on other sites More sharing options...
spmckee Posted March 10, 2010 Author Share Posted March 10, 2010 Thanks mattal999. That's going to do the trick. Link to comment https://forums.phpfreaks.com/topic/194792-finding-single-array-in-multidimensional/#findComment-1024318 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.