Move array item to the last position!

0

I need to move an item from an array to its last position! First I ordered it in high order, but an item needs to be the last one 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);
     }
 }
    
asked by anonymous 22.02.2018 / 21:11

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;
    
22.02.2018 / 21:14