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: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> To contact the list administrators, e-mail: [EMAIL PROTECTED]
> 


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to