1

I have the following array:

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" } 
} 

Is there a way to remove the indexing using a predefined php function and instead format it like this:

array(3) { 
    ["theme_loader_plugin"]=> string(4) "_run",
    ["user_plugin"]=> string(4) "_run",
    ["sessions_plugin"]=> string(4) "_run"
} 
Nelson Owalo
  • 2,324
  • 18
  • 37

1 Answers1

4

Loop through the array and merge them to new array. Hope it will help -

$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);
}

OUTPUT

array(3) {
  ["theme_loader_plugin"]=>
  string(4) "_run"
  ["user_plugin"]=>
  string(4) "_run"
  ["sessions_plugin"]=>
  string(4) "_run"
}
Sougata Bose
  • 31,517
  • 8
  • 49
  • 87