Re: remove from array
| From: | Marcelo Gulin | Date: | Tue, 09 Jan 2001 15:22:41 +0000 |
| Subject: | Re: remove from array | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-33466@lists.php.net to get a copy of this message | ||
Hi!
I think that array_splice function can do that.
try...
$myarray=array(1,2,3,4,5);
array_splice( $myarray, 3, 1);
foreach( $myarray as $element )
print "$element<br>";
this code remove 4 from $myarray
regards
Marcelo Gulin
AJDIN BRANDIC escribió:
>
> Hi,
>
> How can I remove an elent from an array.
>
> ie. myarray=(1,2,3,4,5);
> $num=3;
>
> while (list($key,$value) = each($myarray)) {
> if($num==$value) {
> remove 3 from array so $myarray contains 1,2,4,5
> }
> }
>
> Thanks
>
> Ajdin
>
> --
> 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