Re: another simple array question
| From: | Brent Baisley | Date: | Fri, 18 Nov 2005 14:24:27 +0000 |
| Subject: | Re: another simple array question | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-226044@lists.php.net to get a copy of this message | ||
You may want to use array_key_exists instead of isset. isset will return false in the value for the array is NULL. Basically isset will tell you if there is a value set for the array key, whereas array_key_exists will tell you if the key exists or not, which is what you want.
On Nov 18, 2005, at 9:00 AM, David Grant wrote:
if (isset($values[4])-- Brent Baisley Systems Architect Landover Associates, Inc. Search & Advisory Services for Advanced Technology Environments p: 212.759.6400/800.759.0577unset($values[4]);Cheers, David Grant cybermalandro cybermalandro wrote:I have an array with indexes 0 to 4 and I want to delete an element of the array if the index is equals 4. I want to delete the variable key and value. What is the best way to do so? foreach ($values as $key => $val){ if ($key == "0") { // } if ($key == "3") { // } if ($key == "4") { //delete value from array } } Thanks!!!!!--PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php