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
Post a Comment