2017-10-12 12 views
0

私はこの配列の10番目の値をとる必要がありますか?親切にもこの質問に私を助けてくれますか?PHPで多次元配列の最後の値を取得するには?

array (
[0] => array 
    (
     [0] => 88% 
     [1] => 88% 
     [2] => 88% 
     [3] => 88% 
     [4] => 88% 
     [5] => 88% 
     [6] => 88% 
     [7] => 88% 
     [8] => 88% 
     [9] => 88% 
     [10] => 88% 
    ) 
[1] => Array 
    (
     [0] => 401 MByte 
     [1] => 401 MByte 
     [2] => 401 MByte 
     [3] => 401 MByte 
     [4] => 401 MByte 
     [5] => 401 MByte 
     [6] => 401 MByte 
     [7] => 401 MByte 
     [8] => 401 MByte 
     [9] => 401 MByte 
     [10] => 401 MByte 
    ) 
[2] => Array 
    (
     [0] => 452,947 MByte 
     [1] => 451,651 MByte 
     [2] => 450,626 MByte 
     [3] => 451,137 MByte 
     [4] => 452,628 MByte 
     [5] => 454,383 MByte 
     [6] => 456,065 MByte 
     [7] => 454,829 MByte 
     [8] => 453,094 MByte 
     [9] => 451,930 MByte 
     [10] => 451,923 MByte 
    ) 
) 
+1

各アレイの最初の10個のエントリが必要ですか? –

答えて

0

は、あなたがこのコードは役立つかもしれない各配列

$arr = array_map(function($v) { 
      return array_slice($v, 0, 9); 
     }, $arr); 
var_dump($arr); 
0

end()関数を使用します。ここで

foreach($yourArry as $one) { 
    echo end($one) ; 
} 
0

の最初の10個のエントリを得ることができる方法です。

$myArray = array (
[0] => array 
    (
     [0] => 88% 
     [1] => 88% 
     [2] => 88% 
     [3] => 88% 
     [4] => 88% 
     [5] => 88% 
     [6] => 88% 
     [7] => 88% 
     [8] => 88% 
     [9] => 88% 
     [10] => 88% 
    ) 
[1] => Array 
    (
     [0] => 401 MByte 
     [1] => 401 MByte 
     [2] => 401 MByte 
     [3] => 401 MByte 
     [4] => 401 MByte 
     [5] => 401 MByte 
     [6] => 401 MByte 
     [7] => 401 MByte 
     [8] => 401 MByte 
     [9] => 401 MByte 
     [10] => 401 MByte 
    ) 
[2] => Array 
    (
     [0] => 452,947 MByte 
     [1] => 451,651 MByte 
     [2] => 450,626 MByte 
     [3] => 451,137 MByte 
     [4] => 452,628 MByte 
     [5] => 454,383 MByte 
     [6] => 456,065 MByte 
     [7] => 454,829 MByte 
     [8] => 453,094 MByte 
     [9] => 451,930 MByte 
     [10] => 451,923 MByte 
    ) 
); 

$my_values = array(); 
foreach($myArray as $a) { 
    if(isset($a[10])) 
     $my_values[] = $a[10]; 
} 

var_dump($my_values); //to check the values 
関連する問題