se quello non funziona prova con
ovviamente l'array dev'essere con chiavi numeriche che partono da zero e proseguono progressivamentecodice:<?php function shifta($array) { $tmp = array(); for($i=0;$i<count($array);$i++) { if($i == count($array)-1) { $tmp[0] = $array[$i]; }else{ $tmp[$i+1] = $array[$i]; } } ksort($tmp); reset($tmp); return $tmp; } ?>
se vuoi una funzione che shifti i sottoarray
codice:<?php function shifta($array) { $tmp = array(); for($i=0;$i<count($array);$i++) { if($i == count($array)-1) { $tmp[0] = is_array($array[$i]) ? shifta($array[$i]) : $array[$i]; }else{ $tmp[$i+1] = is_array($array[$i]) ? shifta($array[$i]) : $array[$i]; } } ksort($tmp); reset($tmp); return $tmp; } ?>

Rispondi quotando