Move array item to last position!

Asked

Viewed 130 times

0

People need to move an item from an array to the last position of it! First I ordered it in altabetica order, but an item needs to be the last on the list, how can I do this with PHP ? I have the following code:

 foreach ( $services as $key => $service ) {
     if($service->values->group == "YubPArfPdg7phRfmyRjS") {
         echo($service->values->group);
     }
 }

1 answer

3

You can remove the item you want from the array and add it again (at the end)

Example:

$aux = $services[$key];
unset($services[$key]);
$services[$key] = $aux;
  • 1

    It worked here brother but I used the array_push() msm result.. VLW!

Browser other questions tagged

You are not signed in. Login or sign up in order to post.