I have an array that might look like
$arr = array( array( 'test1' => 'testing1' ), array( 'test2' => array( 1 =>'testing2 ) );
and I want to turn it into
$newArr = array( 'test1' => 'testing1', 'test2' => array( 1 => 'testing2' ) );
so I'm trying to move all elements of the array one level.
Eidt:
this is my method that concatenates 2 arrays together:
public function arrayMerge($arr1, $arr2) { foreach($arr2 as $key => $value) { $condition = (array_key_exists($key, $arr1) && is_array($value)); $arr1[$key] = ($condition ? $this->arrayMerge($arr1[$key], $arr2[$key]) : $value); } return $arr1; }
php
Eli
source share