I need to form a multidimensional array as shown below in the format, however I could not understand the algorithm
array( [0]=>array( "id"=>"1","data"=>array([0]=>array("kid"=>"434","k"=>"Ali","m"=>"msj1"), [1]=>array("kid"=>"344","k"=>"Dali","m"=>"msj3")), [1]=>array( "id"=>"2","data"=>array([0]=>array("kid"=>"347","k"=>"Cenk","m"=>"msj2"), [1]=>array("kid"=>"345","k"=>"Tan","m"=>"msj4")))
The data comes from a MySQL query, as shown below:
CHOOSE kid, k, m, id FROM table1 WHERE rid = 1 ORDER BY (id)
Sample data:
id kid km 1 434 Ali msj1 2 347 Cenk msj2 1 344 Dali msj3 2 345 Tan msj4
Php loop as below:
do { //whatever I tried here failed :( } while ($t = mysql_fetch_assoc($r_tav));
I hope that with this pattern I better understand multidimensional arrays
source share