note 47836 added to function.reset

From: Date: Thu, 02 Dec 2004 06:30:21 +0000
Subject: note 47836 added to function.reset
Groups: php.notes 
Request: Send a blank email to php-notes+get-81262@lists.php.net to get a copy of this message
Be aware that when using reset() to clear an element and key from an array, if auto-incrementing, the new array keys will not reset a key previously set: $temparray[] = "0"; $temparray[] = "1"; $temparray[] = "2"; unset($temparray[2]); $temparray[] = "2"; $temparray[] = "3"; print_r($temparray); The above will return: Array ( [0] => 0 [1] => 1 [3] => 2 [4] => 3 ) When attempting something like this, its better to use array_pop(). hope it helped ---- Manual Page -- http://www.php.net/manual/en/function.reset.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+47836 Delete -- http://master.php.net/manage/user-notes.php?action=delete+47836&report=yes Reason: bad code -- http://master.php.net/manage/user-notes.php?action=delete+47836&report=yes&reason=bad+code Reason: spam -- http://master.php.net/manage/user-notes.php?action=delete+47836&report=yes&reason=spam Reason: useless example -- http://master.php.net/manage/user-notes.php?action=delete+47836&report=yes&reason=useless+example Reason: contains commercial links -- http://master.php.net/manage/user-notes.php?action=delete+47836&report=yes&reason=contains+commercial+links Reason: useless note -- http://master.php.net/manage/user-notes.php?action=delete+47836&report=yes&reason=useless+note Reject -- http://master.php.net/manage/user-notes.php?action=reject+47836&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#81262) next »