Re: Removing All Instances From An Array
| From: | Ed Vul | Date: | Wed, 12 Jul 2000 20:47:50 +0000 |
| Subject: | Re: Removing All Instances From An Array | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-6266@lists.php.net to get a copy of this message | ||
well.... I don't know much but maybe I can get you started on the right
path...
unset($array[$picked]);
will take away that key and value from the array...
you can have a loop like
$val = $array[$picked];
$list = each($array);
while($list[0])
{
if($list[1] == $val)
{
$key = $list[0];
unset($array[$key]);
}
$list = each($array);
}
There may be a few bugs there, and there probably is a more efficient way of
writing that... but you get the idea, hopefully :)
Ed
""Andrew"" <fisherres@msn.com> wrote in message
news:004501bfec40$ff2462e0$4336173f@8vrta...
> Hello,
>
> 1. I have an array $array = array (1,2,3,3,3,4,5,6,7,8,9,9);
> 2. The variable $picked has the value 2.
> 3. If I print the value of $array[$picked] I see the number three.
> 4. Well instead of printing the number three I want to remove all
instances
> of 3 from the array. So, my array should look like $array = array
> (1,2,4,5,6,7,8,9,9);
>
> Basically, whatever the value of $array[picked] is, I want to remove
all
> instances of that value from the array.
>
> Andrew
> digi-FX
> -------------------------------
> http://www.digi-FX.net
>
>
>
> --
> 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
>