我在codeigniter-php中这样做: 我有这样的输出:
var_dump($x);
array
0 => string 'Start Date :' (length=12)
1 => string '1-Aug-15' (length=8)
array
0 => string 'End Date :' (length=10)
1 => string '19-Aug-15' (length=9)
array
0 => string 'Txn Date' (length=8)
1 => string 'Value Date' (length=10)
2 => string 'Description' (length=11)
3 => string 'Ref No./Cheque No.' (length=18)
4 => string 'Branch Code' (length=11)
5 => string 'Debit' (length=5)
6 => string 'Credit' (length=6)
7 => string 'Balance' (length=7)
但我想要包含6个子阵列的数组:我希望获得这个数组:我有很多包含6个子数组和2个子数组的数组,但是我想要6个子数组同时使用array.please help:
array
0 => string 'Txn Date' (length=8)
1 => string 'Value Date' (length=10)
2 => string 'Description' (length=11)
3 => string 'Ref No./Cheque No.' (length=18)
4 => string 'Branch Code' (length=11)
5 => string 'Debit' (length=5)
6 => string 'Credit' (length=6)
答案 0 :(得分:1)
function getSubArray(Array $arr, $l = 6) {
foreach($arr as $subArr) {
if (is_array($subArr) && count($subArr) === $l) {
return $subArr;
}
}
return null;
}
$result = getSubArray($x);