本文介绍了转换的MultiArray到SingleArray没有的foreach的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如果我有一个数组,里面坐了一个单一的阵列。有没有办法推子数组值到父无需运行一个foreach?
例如,如果我有一个数组是这样的:
阵列([0] =>阵列(
KEY1=> 值1
KEY2=> VALUE2
KEY3=> 值3
)
);
和我想要将其降低到这一点:
阵列(
KEY1=> 值1
KEY2=> VALUE2
KEY3=> 值3
);
是否有这样做没有一个foreach的一种方式?
目前我在做这样的:
$ singleArr =阵列();
的foreach($ multiArr为$ subArr){
$ singleArr = $ subArr;
}
解决方案
有关简单什么:
$ singleArr = $ multiArr [0];
If I have an array, with a single array inside it. Is there a way push the child array values into the parent without having to run a foreach?
For example, if I have an array like this:
array( [0] => array(
"key1" => "value1",
"key2" => "value2",
"key3" => "value3",
)
);
and I want to reduce it to this:
array(
"key1" => "value1",
"key2" => "value2",
"key3" => "value3",
);
Is there a way of doing this without a foreach?
at the moment I'm doing this:
$singleArr = array();
foreach($multiArr as $subArr) {
$singleArr = $subArr;
}
解决方案
What about simple:
$singleArr = $multiArr[0];
这篇关于转换的MultiArray到SingleArray没有的foreach的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!