PHP Multidimensional associative arrays -


i wondering if code have multidimensional associative array. ask because after doing research on multidimensional arrays could't find difference between 2 because looked same. code associative array or standard multidim array?

$win = array('name'=>                          array('jane doe ', 'nash patel ', 'joe public '),               'date'=>                         array('7 october 2015 ', '14 october 2014 ', '12 october 2016 '));  foreach($win $element => $namedate) {     echo '<strong>' . $element . '</strong><br>';     foreach($namedate $both) {        echo $both . '<br/>';     } } 

you have multidimensional array.

the first level associative because keys name , date.

the second level subarrays indexed (not associative). means jane doe's index 0, nash patel 1, , joe public 2.

although can if wish, keys not need written when declaring indexed elements -- php spare tedious job.

examples:

$one_dim=['name'=>'jane doe ']; // 1-dimensional associative array 1 element  $one_dim=['jane doe '];         // 1-dimensional indexed array 1 element  $mult_dim=[                     // multi-dimensional associative array indexed subarrays     'name'=>[                   // associative         0=>'jane doe ',         // indexed         1=>'nash patel ',       // indexed         2=>'joe public '        // indexed     ],     'date'=>[                   // associative         0=>'7 october 2015 ',   // indexed         1=>'14 october 2014 ',  // indexed         2=>'12 october 2016 '   // indexed     ] ]; 

Comments

Popular posts from this blog

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

python Tkinter Capturing keyboard events save as one single string -

sql server - Why does Linq-to-SQL add unnecessary COUNT()? -