php array_merge associative arrays

后端 未结 7 1268
天命终不由人
天命终不由人 2020-12-09 08:41

I\'m trying to prepend an item to the beginning of an associative array. I figured the best way to do this is to use array_merge, but I\'m having some odd consequences. I

7条回答
  •  长情又很酷
    2020-12-09 09:02

    You could use array operator: +

    $products = array(0 => "Select a product" ) + $products;
    

    it will do a union and only works when the keys don't overlap.

提交回复
热议问题