我尝试使用array_push,但结果并不是我需要的。我需要一个不同的结果集,但我不确定如何处理array_push。或者有不同的方法来做到这一点吗?
$array[0][0] = 0;
$array[0][1] = 0;
$array[0][2] = 0;
$array[1][0] = 1;
$array[1][1] = 1;
$array[1][2] = 1;
$array[2][0] = 2;
$array[2][1] = 2;
$array[2][2] = 2;
$count = count($array);
$tempArray = array();
while ($count > 0) {
$count--;
if ($array[$count][2] > 0) {
array_push($tempArray, $array[$count][0], $array[$count][1]);
} //end of if ($array[$count][2] > 0)
} //end of while ($count > 0)
print_r($tempArray);
结果:
Array ( [0] => 1 [1] => 1 [2] => 2 [3] => 2 )
需要结果:
Array ( [0][0] => 1 [0][1] => 1 [1][0] => 2 [1][1] => 2 )