On Tue, 2007-07-10 at 14:23 -0700, Dan wrote:
> I know in some languages there's a right way to remove an element from an 
> array and other ways that will give you problems.
> 
> In PHP can I just set $arrayname[key] = null?  Or will I then end up with 
> key => null as a value.  I looked on php.net under array functions for a bit 
> and I didn't find any sort of remove element function.  I've just never 
> needed to do this before.

It would have taken you less time to test than to write the email:

<?php

$array = array
(
    1 => 'One',
    2 => 'Two',
    3 => 'Three',
);

$array[2] = null;
print_r( $array );

unset( $array[2] );
print_r( $array );

?>

Cheers,
Rob.
-- 
...........................................................
SwarmBuy.com - http://www.swarmbuy.com

    Leveraging the buying power of the masses!
...........................................................

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to