Re: Emptying a Single Array Value
| From: | Kevin Stone | Date: | Wed, 12 Jun 2002 19:05:48 +0000 |
| Subject: | Re: Emptying a Single Array Value | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-101797@lists.php.net to get a copy of this message | ||
$nums = array ('one', 'two', 'three');
$nums = remove_array_element($nums, 1);
function remove_array_element($array, $index)
{
unset($array[$i]); // Unset selected index
return array_values($array); // Return reindexed array
}
P.S. The empty() function returns true or false depending upon whether or
not the variable you pass to contains information, it doesn't affect the
variable.
-Kevin
----- Original Message -----
From: "Martin Clifford" <MLC1@nrc.gov>
To: <php-general@lists.php.net>
Sent: Wednesday, June 12, 2002 12:48 PM
Subject: [PHP] Emptying a Single Array Value
> Howdy,
>
> If someone out there could tell me how to get rid of a single key/index
pair within an array, it would be great. I've tried both unset() and
empty(), but both destroy the entire array.
>
> Please CC me directly, as I'm on the digest.
>
> Thanks in advance!
>
> Martin
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>