Re: Poping array which has the matching value

From: Date: Thu, 21 Dec 2006 10:11:19 +0000
Subject: Re: Poping array which has the matching value
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-246116@lists.php.net to get a copy of this message
Che Hodgins wrote:
Leo, $letters = array('a', 'b', 'c', 'd', 'e', 'f'); $key = array_search('c', $letters);
you can also try unset( $letters[$key] ); sumeet
$value = array_splice($letters, $key, 1); $value[0] will contain 'c' $letters will contain Array ( [0] => a [1] => b [2] => d [3] => e [4] => f ) regards, Che On 12/21/06, Leo Liu <kkl_sg@yahoo.com> wrote:
Hi, I wanted to search through the array and pop out the value which match my search criteria. For example If array has {a,b,c,d,e,f} I wanna search for "c" and once I found it, took it out from the array. So the result of the array after operation will be {a,b,d,e,f} If I do array_pop(); function it will only pop the last element inside the array and the array will become {a,b,c,d,e} Anyway to search the desire element inside the array and took it out from the array? Regards, Leo Reality starts with Dream __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com
-- Thanking You Sumeet Shroff http://www.prateeksha.com Web Designers and PHP / Mysql Ecommerce Development, Mumbai India

« previous php.general (#246116) next »