Hi, I've been looking through the PHP Manual but can't seem to find a sollution to my problem. It's not an uncommon problem so I'm sure there is an easy way of handling it.
I am strying to search an array for a particular value if it found then move this value to the front of the array. This is what I developed.
<?php
function movetotop($code) {
global $the_array;
if(in_array($code,$the_array)) {
$pos=array_search($code, $the_array);
array_unshift($the_array,$code);
unset($the_array[($pos+1)];
}
?>
However the problem I am having with this is holes in the array. Where the element is being moved from (and unset from) there is a blank whole. What I would like to happen is for all the elements after to move down much like if I had done the whole operation with a stack.
Thanks in advance
Bubble