0

我有一些代码正在生成这个数组(为了便于阅读而分解它):

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 顺便说一句。

4

3 回答 3

2

试试array_pop($array)。它将从数组中弹出最后一个元素并返回它。

更新:

$buffer = array();
foreach ($arrays as $array) {
    $buffer = array_pop($array);
}

我想这就是你的意思。

于 2013-05-15T21:55:09.917 回答
0

让你的数组命名为 $long_arr

$target_array = array_values($long_arr); 
var_dump($target_array);
于 2013-05-16T02:52:03.113 回答
0

这条评论为我做了:

如果您使用 count($your_array) 它是否可以很好地计算行数??...如果计数很好,那么您可以检索最后一行,例如 $row = $your_array[count($your_array)-1]; ——罗伯特·罗萨斯 18 小时前

于 2013-05-16T16:59:20.273 回答