php - Accessing data within an array -


i create array ends quite bit of data. example of array so.

array:9 [▼   0 => array:9 [▼     "id" => "1232806"     "date" => "21/04/2016"     "name" => "test"     "owner" => "someone"     "value" => "2160.00"     "status/stage" => "70%"     0 => array:2 [▼       "structure" => ""       "prospect" => "no"     ]     1 => array:2 [▼       0 => array:8 [▼         "quote id" => "q0020"         "name" => "test"         "amount" => "2160"       ]       1 => array:2 [▼         0 => array:1 [▼           "type" => "new"         ]         1 => array:1 [▼           "month" => "june 16"         ]       ]     ]   ] ] 

i trying data out of array. can top level items out without issue

foreach ($array $data) {     echo $data["id"];     echo $data["date"];     echo $data["name"];     ... } 

i struggling inner data however. trying like

foreach ($array $data) {     echo $data["id"];     echo $data["date"];     echo $data["name"];     foreach ($data $innerdata) {         echo innerdata["structure"];         echo innerdata["prospect"];     } } 

if however, complains illegal string offset. how can access different data within array?

thanks

created question showing how collect data doing wrong https://stackoverflow.com/questions/36837239/processing-xml-data-into-array

try per below flow:

foreach ($array $k=>$data) {         echo $data["id"];         echo $data["date"];         echo $data["name"];     if(is_numeric($k) && is_array($data))     {          foreach ($data $innerdata) {         echo innerdata["structure"];         echo innerdata["prospect"];         }     } } 

}


Comments

Popular posts from this blog

javascript - How to get current YouTube IDs via iMacros? -

c# - Maintaining a program folder in program files out of date? -

emulation - Android map show my location didn't work -