Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?
- $array[0] = 'aap';
- $array[1] = 'noot';
- $array[3] = 'mies';
- $array[7] = 'wim';
- $array[8] = 'zus';
- $array[9] = 'jet';
- print_r($array); // print the array
- echo '<br />';
- $size = count($array); // 6 elements in array
- $r = 0; // read position
- $i = 0; // insert position
- while($i < $size){
- if(isset($array[$r])){ // if there is an element at read position
- $temp = $array[$r]; // read the value into a temp variable
- unset($array[$r]); // unset (remove from array) the read value
- $array[$i] = $temp; // place it into the array at insert position
- $i++; // increase inster position
- }
- $r++; // increase read position
- }
- print_r($array);
- ?>
Add Comment
Please, Sign In to add comment