loops - php foreach multidimensional associative array -


i have multidimensional associative array follows

  sr_array=>     array (size=18)   0 => string 'shop' (length=4)   1 => string 'papu kushwaha' (length=13)   2 => string 'jitendra shukla' (length=15)   3 => string 'satish' (length=6)   4 => string 'pradeep' (length=7)   5 => string 'papu khan' (length=9)   6 => string 'bharat' (length=6)   7 => string 'manoj pandey' (length=12)   8 => string 'select' (length=6)   'shop' =>      array (size=9)       'count_auto' => int 60       'count_indus' => int 4       'count_mc' => int 100       'count_inverter' => int 10       'count_in_bat' => int 40       'total_credit' => int 191850       'sale_value' => int 1351755       'total_disc' => float 22377.38       'perc_disc' => float 1.66 

and on....

now want print them in table format have used following code output

echo"<table border=1>";             echo"<tr>";             echo"<th></th>";           for($i=0; $i < count($sr_array)/2; $i++){             $current_sr = $sr_array[$i];             echo"<th>{$current_sr}</th>";         }         echo"</tr>";          $keys = array_keys($sr_array);          for($i=0; $i < count($sr_array)/2; $i++){             $current_sr = $sr_array[$i];             echo"<tr>";             echo"<td></td>";              foreach($sr_array $key => $var){                  foreach($var $x => $y)                     echo"<td>{$y["count_auto"]}</td>";              }              echo"</tr>";         } 

please me out as

------------------------------------- |           |shop    |xyz      |abc   | ------------------------------------- count_auto  |60      |75       | 85   | ------------------------------------- count_indus | 25     | 74      |15    | -------------------------------------- count_mc    |  55    | 212     | 15   | ------------------------------------- 

and on

i getting error invalid argument supplied foreach()

thanks in advance

the fundamental issue here when iterating on sr_array, assuming values arrays. not case index 0 through 8 (from can tell). explain immediate issue.

ideally, structure of array consistent (ideally, two-dimensional array of rows, each containing set of fields), simple nested loop work.


Comments

Popular posts from this blog

php - Admin SDK -- get information about the group -

dns - How To Use Custom Nameserver On Free Cloudflare? -

Python Error - TypeError: input expected at most 1 arguments, got 3 -