phparrayssorting

Pushing Element to the top of an array PHP


I have the following array:

  0 =  Stat.clicks
  1 =  Stat.currency
  2 =  Stat.conversions
  3 =  Stat.payout
  4 =  Stat.ltr

Now if i want to push the element Offer.name ontop of this array without deleting Stat.clicks which is index 0 how would i do that?


Solution

  • You would do:

    array_unshift($array, 'Offer.name');