php - keys and values of dynamically generated array -


i have array:

 array (     [0] => array         (             [dated] => 2017-04-01             [nadeem] => 1995             [nadeemkaat] => 40             [ali] => 0             [alikaat] => 0             [usman] => 0             [usmankaat] => 0         )      [1] => array         (             [dated] => 2017-04-06             [nadeem] => 0             [nadeemkaat] => 0             [ali] => 4800             [alikaat] => 96             [usman] => 0             [usmankaat] => 0         )      [2] => array         (             [dated] => 2017-04-20             [nadeem] => 0             [nadeemkaat] => 0             [ali] => 0             [alikaat] => 0             [usman] => 2100             [usmankaat] => 42         )  ) 

i want print out array values this:

 date          | nadeem | ali    | usman 2017-04-01    | 1995   |        | 2017-04-06    |        | 4800   | 2017-04-20    |        |        |2100 

i confuse here how handle kind of array, please me out trying foreach loop

foreach ($stock $key => $value)  {  echo $key . $value; } 

try this:

if (!empty($stock)) { echo '<table><tr>'; foreach ($stock[0] $key => $value)  {     echo '<th>' . $key . '</th>'; } echo '</tr>';  foreach ($stock $value)  {     echo '<tr>';     foreach ($value $key2 => $field) {         echo '<td>' . $field . '</td>';     }     echo '</tr>'; } echo '</table>'; } 

Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

thorough guide for profiling racket code -