note 41236 added to function.unset

From: Date: Sat, 03 Apr 2004 17:00:36 +0000
Subject: note 41236 added to function.unset
Groups: php.notes 
Request: Send a blank email to php-notes+get-67581@lists.php.net to get a copy of this message
I have being trying to use unset to _remove_ an item from an array. While unset deletes the key and value from the array, and print_r does not show the deleted key, there is still something in the array. If you use foreach to loop through the array the deleted key will still show as blank key. The only way to over come this was this: foreach ($values as $key=>$value) { if ($key != '') { $q .= " $key = '".mysql_escape_string($value)."',"; } } I tried using array values to re-index the array but that did not help. Is there a way to actually delete an item from an array, including it's key, value and position in index ? Will ---- Manual Page -- http://www.php.net/manual/en/function.unset.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+41236 Delete -- http://master.php.net/manage/user-notes.php?action=delete+41236&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+41236&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#67581) next »