Re: delete element from an array

From: Date: Thu, 20 Sep 2001 06:09:27 +0000
Subject: Re: delete element from an array
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-67945@lists.php.net to get a copy of this message
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 ?> Regards, Philip Olson On Thu, 20 Sep 2001, Miroslav Figlar wrote: > Hi, > > what is the best way to delete element from an array? > Suppose i have an array called $numbers: > $numbers = array(a => 10, b => 20, c => 30, d => 40); > I want to delete the third element from that array. > > Thank you > > Miro Figlar > > > > -- > 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 (#67945) next »