Loop through Array, with Similar items First in PHP -


array ( [0] => array     (         [intid] => 3         [intvolumetype] => 1         [intvolume] => 10         [totalvolumes] => 10         [inttrack] => 10         [inttracktype] => 2         [totaltracks] => 10     )  [1] => array     (         [intid] => 4         [intvolumetype] => 2         [intvolume] => 100         [totalvolumes] => 200         [inttrack] => 111         [inttracktype] => 3         [totaltracks] => 222     ) 

)

i want print above array as:
intvolumetype = 1
totalvolumes = 10
intvolumetype = 2
totalvolumes = 200


inttracktype = 2
totaltracks = 10
inttracktype = 3
totaltracks = 222

how loop through php array. there total 6 elements in array. might increase upto 20. print first volume information, track, , on.please help

try here: http://phpfiddle.org/

<?php $a = array     (     0 => [         'intid' => 3,         "intvolumetype" => 1,         "intvolume" => 10,         "totalvolumes" => 10,         "inttrack" => 10,         "inttracktype" => 2,         "totaltracks" => 10,     ],     1 => [         "intid" => 4,         "intvolumetype" => 2,         "intvolume" => 100,         "totalvolumes" => 200,         "inttrack" => 111,         "inttracktype" => 3,         "totaltracks" => 222,     ] ); /*echo "<pre>"; print_r( $a ); echo "</pre>"; */ // have manually $volume = ""; $track = ""; foreach ( $a $item ) {     // preparing volumes types     $volume .= "intvolumetype = " . $item['intvolumetype'] . "<br/>";     $volume .= "totalvolumes = " . $item['totalvolumes'] . "<br/>";     // can add other variables     $volume .= "<br/>";     // preparing track types     $track .= "inttracktype = " . $item['inttracktype'] . "<br/>";     $track .= "totaltracks = " . $item['totaltracks'] . "<br/>";     // can add other variables       $track .= "<br/>"; } echo $volume; echo "===================<br/>"; echo $track; ?> 

Comments

Popular posts from this blog

wordpress - (T_ENDFOREACH) php error -

Export Excel workseet into txt file using vba - (text and numbers with formulas) -

Using django-mptt to get only the categories that have items -