Merge “Defaults” array with “Input” array? PHP Which Function?

后端 未结 5 1892
野的像风
野的像风 2021-02-14 15:43

Lets say you are having a user provide information.

Array 1

But not all is required. So you have defaults.

Array 2
         


        
5条回答
  •  夕颜
    夕颜 (楼主)
    2021-02-14 16:40

    You can just do something like

    foreach($array1 as $key=>$value) $array2[$key]=$value;
    

提交回复
热议问题