This post was last edited by qq914260102 on 2013-11-14 10:08:13
For example, I have 100 records in a recordset $row.
for ($k =0; $k <$100; $k + +) {
$arr =array ($a [$k], $b [$k], $c [$k]);
Print_r ($arr);
}
I can now put these 100 loops out, is 100 a only array, I now want to turn this into a two-dimensional array, write hair.
Reply to discussion (solution)
for ($k =0; $k <$100; $k + +) { $arr []=array ($yid [$k], $title [$k], $link [$k])); Print_r ($arr);}
$array 1 = Array (' 1 ', ' 2 ', ' 3 '), $array 2 = Array (' 1 ', ' 2 ', ' 3 '), $arr = Array (); for ($k =0; $k <100; $k + +) {//This is not $100$arr[]= Array ($array 1[$k], $array 2[$k]);} echo "";p Rint_r ($arr);
I'll go. Color added wrong.
$array 1 = Array (' 1 ', ' 2 ', ' 3 '), $array 2 = Array (' 1 ', ' 2 ', ' 3 '), $arr = Array (); for ($k =0; $k <100; $k + +) {$arr []=array ($ array1[$k], $array 2[$k]);} echo "";p Rint_r ($arr);
While $row
{
$arr [$row ["id"]]= $row ["name"];
}
I just finished it, and I found this method most convenient.
For example, I have 100 records in a recordset $row.
for ($k =0; $k <$100; $k + +) {
$arr =array ($a [$k], $b [$k], $c [$k]);
Print_r ($arr);
}
I can now put these 100 loops out, is 100 a only array, I now want to turn this into a two-dimensional array, write hair.
As the result of the above output is
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 the result of this. ,
is $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're talking about a two-dimensional array.
foreach ($row as $val) { print_r ($val);}
You're talking about a two-dimensional array.
foreach ($row as $val) { print_r ($val);}
Specific code.