PHP removing an array element and inserting it into another array -


i have 2 arrays in same form below; examples sake, lets call them $array1 , $array2

array (     [element1] => array         (             [id] => 11             [morethings] => 145             [somemore] => namehere         )     [element2] => array         (             [id] => 11             [morethings] => 145             [somemore] => namehere         )     [element3] => array         (             [id] => 11             [morethings] => 145             [somemore] => namehere         ) ) 

what need take element2 first array , insert array2 newelement2

i have following below keeps returning nothing @ in array2

$searcharray = array_search('element2', $array1); array_splice($array2, $searcharray, 1, array('newelement2')); 

any appreciated.

for assign value can

 $array2['element2'] = $array1['element2']; 

(this append or repalce entry elemet2 in $array2)

and remove value

 unset($array1['element2']); 

Comments

Popular posts from this blog

ubuntu - PHP script to find files of certain extensions in a directory, returns populated array when run in browser, but empty array when run from terminal -

php - How can i create a user dashboard -

javascript - How to detect toggling of the fullscreen-toolbar in jQuery Mobile? -