php array_merge associative arrays

后端 未结 7 1265
天命终不由人
天命终不由人 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:11

    You could try something like

    $products[0]='Select a Product'
    ksort($products);
    

    That should put the 0 at the start of the array but it will also sort the other products in numeric order which you may not want.

提交回复
热议问题