我有一些代码正在生成这个数组(打破它以便于阅读):
Array ( [0] => 78 ) 78
Array ( [0] => 78 [1] => 75 ) 75
Array ( [0] => 78 [1] => 75 [2] => 72 ) 72
Array ( [0] => 78 [1] => 75 [2] => 72 [3] => 68 ) 68
Array ( [0] => 78 [1] => 75 [2] => 72 [3] => 68 [4] => 65 ) 65
Array ( [0] => 78 [1] => 75 [2] => 72 [3] => 68 [4] => 65 [5] => 62 ) 62
Array ( [0] => 78 [1] => 75 [2] => 72 [3] => 68 [4] => 65 [5] => 62 [6] => 59 ) 59
Array ( [0] => 78 [1] => 75 [2] => 72 [3] => 68 [4] => 65 [5] => 62 [6] => 59 [7] => 56 ) 56
Array ( [0] => 78 [1] => 75 [2] => 72 [3] => 68 [4] => 65 [5] => 62 [6] => 59 [7] => 56 [8] => 37 ) 37
Array ( [0] => 78 [1] => 75 [2] => 72 [3] => 68 [4] => 65 [5] => 62 [6] => 59 [7] => 56 [8] => 37 [9] => 36 ) 36
我需要的是最后一个数组。具有单独存储的所有数字的那个。我怎样才能做到这一点?在php btw。
答案 0 :(得分:2)
试试array_pop($array)
。它将从数组中弹出最后一个元素并将其返回。
更新
$buffer = array();
foreach ($arrays as $array) {
$buffer = array_pop($array);
}
我认为这就是你的意思。
答案 1 :(得分:0)
将数组命名为$ long_arr
$target_array = array_values($long_arr);
var_dump($target_array);
答案 2 :(得分:0)
这条评论为我做了:
如果使用count($ your_array)它会很好地计算行数......如果计数好,那么你可以检索最后一行,比如$ row = $ your_array [count($ your_array)-1] ; - Robert Rozas 18小时前