php - 将数组推入数组 - 关键问题
我试图将多个数组推入1个大数组中,从而产生一个2 lvl数组。
例如,我得到了这组数组:
Array ( [cod] => ddd [denum] => ffffffffffffffff [descr] => ggggggg [cant] => 3 ) Array ( [cod] => fff [denum] => dfgdfgdfgdfgdfg [descr] => dfgdfgdfgdfgdfg [cant] => 33 )
但是,在数组推送之后,我得到这个数组:
Array ( [0] => Array ( [0] => ddd [1] => ffffffffffffffff [2] => ggggggg [3] => 3 ) [1] => Array ( [0] => fff [1] => dfgdfgdfgdfgdfg [2] => dfgdfgdfgdfgdfg [3] => 33 ) )
基本上这就是我想做的,但是,如果你在按下后注意到,键就会被遗忘,并转换为数字。
这就是我想要的样子:
Array ( [0] => Array ( [cod] => ddd [denum] => ffffffffffffffff [descr] => ggggggg [cant] => 3 ) [1] => Array ( [cod] => fff [denum] => dfgdfgdfgdfgdfg [descr] => dfgdfgdfgdfgdfg [cant] => 33 ) )
示例代码 im 使用:
$res_arr_values = array();
while ($row = mysql_fetch_array($result, MYSQL_ASSOC))
{
array_push($res_arr_values, array_values($row));
}
有人可以帮我吗?