Re: Quick array question

From: Date: Tue, 30 Oct 2001 19:27:52 +0000
Subject: Re: Quick array question
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-72916@lists.php.net to get a copy of this message
Check out this post: http://marc.theaimsgroup.com/?l=php-general&m=100096614905023 Which reads: Here's an example using unset() and array_splice(), notice the subtle difference: <?php $foo = array('a','b','c'); unset($foo[1]); print_r($foo); // [0] => a [2] => c $bar = array('a','b','c'); $piece = array_splice ($bar, 1 ,1); print_r($piece); // [0] => b print_r($bar); // [0] => a [1] => c ?> Okay, no need to check the old post now :) Check out : http://uk.php.net/array_slice http://uk.php.net/array_splice regards, Philip Olson On Tue, 30 Oct 2001, David Yee wrote: > That doesn't seem to do what I want. That would only unset the value for > the element, but the element is still there. E.g. > > $a = array(1,2,3,4,5) > > unset($a[2]); > > $a now = (1, 2, NULL, 4, 5), but I want (1, 2, 3, 4). > > David > > ----- Original Message ----- > From: "Matt Williams" <matt@yewlands.com> > To: "David Yee" <david@coolcomputing.com>; <php-general@lists.php.net> > Sent: Tuesday, October 30, 2001 10:49 AM > Subject: RE: [PHP] Quick array question > > > > Just found this in the manual notes > > > > http://www.php.net/manual/en/ref.array.php > > > > To delete an element from an array in an easy way, use > > unset($array["element"]);... > > > > Funny those... manuals > > > > M: > > > > > -----Original Message----- > > > From: David Yee [mailto:david@coolcomputing.com] > > > Sent: 30 October 2001 19:03 > > > To: php-general@lists.php.net > > > Subject: [PHP] Quick array question > > > > > > > > > Hi. Is there an array function that deletes an array element > > > (that's not at the beginning or the end of the array) and return > > > the resultant array? E.g. this is what I want to do: > > > > > > $a = array(1, 2, 3, 4, 5); > > > > > > $b = array_element_delete_function($a, 2); > > > > > > $b now has 4 elements with the following values: (1, 2, 4, 5) > > > > > > Thanks. > > > > > > David > > > > > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net > For additional commands, e-mail: php-general-help@lists.php.net > To contact the list administrators, e-mail: php-list-admin@lists.php.net >

« previous php.general (#72916) next »