我目前有一个如下所示的阵列:
Array
(
[0] => Array
(
[language] => English
)
[1] => Array
(
[language] => Arabic
)
[2] => Array
(
[language] => Bengali
)
)
我想做的是改变它,看起来像这样:
Array
(
[language] => Array
(
[0] => English
[1] => Arabic
[2] => Bengali
)
)
我还有一个如下所示的数组:
Array
(
[id] => 3
[name] => lethalMango
[joined] => 2010-01-01 00:00:00
)
我想将其更改为:
Array
(
[user] => Array
(
[id] => 3
[name] => lethalMango
[joined] => 2010-01-01 00:00:00
)
)
我尝试了很多方法但没有取得多大成功,但我确信有更有效的方法。
答案 0 :(得分:4)
FIRST :
$result = array();
foreach($array as $value){
$result['language'][]= $value['language']
}
SECOND :
$result['user'] = $array;
答案 1 :(得分:1)
第二
$result = array('user'=>$array);