php array_merge without erasing values?

前端 未结 6 1045
南旧
南旧 2020-12-16 15:23

Background: Trevor is working with a PHP implementation of a standard algorithm: take a main set of default name-value pairs, and update those name-value pa

6条回答
  •  遥遥无期
    2020-12-16 15:40

    Well, if you want a "clever" way to do it, here it is, but it may not be as readable as simply doing a loop.

    $merged = array_merge(array_filter($foo, 'strval'), array_filter($bar, 'strval'));
    

    edit: or using +...

提交回复
热议问题