I got a record set row. how can I read all the record sets to form a two-dimensional array. This post was last edited by qq914260102 at 10:08:13, January 14 ,.
For example, I have one hundred records in a record set $ row.
For ($ k = 0; $ k <$100; $ k ++ ){
$ Arr = array ($ a [$ k], $ B [$ k], $ c [$ k]);
Print_r ($ arr );
}
Now I can loop these one hundred entries into one hundred unique arrays. now I want to turn this into a two-dimensional array and write and send it ..
Reply to discussion (solution)
for($k=0;$k<$100;$k++){ $arr[]=array($yid[$k],$title[$k],$link[$k])); print_r($arr);}
$ Array1 = array ('1', '2', '3'); $ array2 = array ('1', '2', '3 '); $ arr = array (); for ($ k = 0; $ k <100; $ k ++) {// here not $100 $ arr [] = array ($ array1 [$ k], $ array2 [$ k]);} echo"";print_r($arr);
I will go. The color is incorrect.
$ Array1 = array ('1', '2', '3'); $ array2 = array ('1', '2', '3 '); $ arr = array (); for ($ k = 0; $ k <100; $ k ++) {$ arr [] = array ($ array1 [$ k], $ array2 [$ k]);} echo"";print_r($arr);
While $ row
{
$ Arr [$ row ["id"] = $ row ["name"];
}
I just found this method the most convenient
For example, I have one hundred records in a record set $ row.
For ($ k = 0; $ k <$100; $ k ++ ){
$ Arr = array ($ a [$ k], $ B [$ k], $ c [$ k]);
Print_r ($ arr );
}
Now I can loop these one hundred entries into one hundred unique arrays. now I want to turn this into a two-dimensional array and write and send it ..
The output result is as follows:
Array ([0] => a1 [1] => b1 [2] => c1)
Array ([0] => asdf2 [1] => b2df [2] => b2sd)
Array ([0] => a3 [1] => b3 [2] => b6)
Array ([0] => a4 [1] => b4 [2] => sdfs)
I want this result .,
Yes $ test = Array ([0] => a1 [1] => b1 [2] => c1 ), array ([0] => asdf2 [1] => b2df [2] => b2sd ), array ([0] => a3 [1] => b3 [2] => b6 ), array ([0] => a4 [1] => b4 [2] => sdfs)
You are talking about two-dimensional arrays.
foreach($row as $val){ print_r($val);}
You are talking about two-dimensional arrays.
foreach($row as $val){ print_r($val);}
Find the specific code.