从数组中删除索引

时间:2015-05-15 12:52:00

标签: php

我有以下数组:

array(3) { 
    [0]=> array(1) { ["theme_loader_plugin"]=> string(4) "_run" } 
    [1]=> array(1) { ["user_plugin"]=> string(4) "_run" } 
    [2]=> array(1) { ["sessions_plugin"]=> string(4) "_run" } 
} 

有没有办法使用预定义的php函数删除索引,而是将其格式化为:

array(3) { 
    ["theme_loader_plugin"]=> string(4) "_run",
    ["user_plugin"]=> string(4) "_run",
    ["sessions_plugin"]=> string(4) "_run"
} 

1 个答案:

答案 0 :(得分:3)

循环遍历数组并将它们合并到新数组。希望它会有所帮助 -

android.os.Process.killProcess(android.os.Process.myPid());

<强>输出

$arr = array( 
   array("theme_loader_plugin"=>  "_run" ) ,
   array("user_plugin"=> "_run" ) ,
   array("sessions_plugin"=> "_run" )
) ;

$new=  array();
foreach($arr as $val) {
  $new = array_merge($new, $val);
}