On Tuesday 30 October 2001 20:33, David Yee wrote: > Well for that example I'm using 0 as the index for the first element of > the array, so deleting element #2 results in 3 being deleted. BTW to > correct myself in the second example I gave I want: > > $a = (1,2,4,5) instead of (1,2,3,4). > > > $a = array(1,2,3,4,5) > > > > unset($a[2]); > > > > $a now = (1, 2, NULL, 4, 5), but I want (1, 2, 3, 4).
Now do you want (1, 2, 4, 5) or (1, 2, 3,4 ) ? If second: So you want the array always to contain a continuous list of numbers (1..n) ? So it's irrelevant *what* element of the array you delete, only *how many* elements you delete? Why not just store the maximum value then and use $MaxVal-- instead of unset ($a[something]), $Index - 1 instead of $a[$Index] ? If the first: remember that arrays in PHP are always associative. So you get (0 => 1, 1 => 2, 3 => 4, 4 => 5) if you want the keys "reordered" you could use array_values() on that.. -- Christian Reiniger LGDC Webmaster (http://lgdc.sunsite.dk/) "Never doubt that a small group of thoughtful, committed people can change the world... Indeed, it's the only thing that ever has." - Margaret Mead -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]