Put new data to specific keys in array PHP -


i want add data existing array without modifying of existing keys or values.

the original array this:

array(     'sections' => array(         array(             'id' => 'sections_id',             'title' => 'sections_title'         )      ),     'settings' => array(         array(             'id' => 'settings_id',             'title' => 'settings_title'         )     ) ); 

now want ablle add new arrays sections key , settings key turn following :

array(     'sections' => array(         array(             'id' => 'sections_id',             'title' => 'sections_title'         ),         array(             'id' => 'new_sections_id',             'title' => 'new_sections_title'         )                ),     'settings' => array(         array(             'id' => 'settings_id',             'title' => 'settings_title'         ),         array(             'id' => 'new_settings_id',             'title' => 'new_settings_title'         )     ) ); 

i tried using array_push , array_merge without success hope can help.

thank you!

you other array.

$array['sections'][] = array('id' => 'sec_id', 'title' => 'sec_title'); 

Comments

Popular posts from this blog

php - SPIP: From Tag directly to an article -

jquery - isAjaxRequest always return false -

ruby on rails - In a controller spec, how to find a specific tag in the generated view? -