Push item to associative array in PHP

后端 未结 12 1427
野趣味
野趣味 2020-12-04 22:47

I\'ve been trying to push an item to an associative array like this:

$new_input[\'name\'] = array(
    \'type\' => \'text\', 
    \'label\' => \'First          


        
12条回答
  •  再見小時候
    2020-12-04 23:42

    WebbieDave's solution will work. If you don't want to overwrite anything that might already be at 'name', you can also do something like this:

    $options['inputs']['name'][] = $new_input['name'];

提交回复
热议问题