|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #151 unset($array["key"]) cuts the whole rest of $array
Submitted: 1998-03-06 09:08 UTC Modified: 1998-03-21 06:36 UTC
From: short at ucw dot cz Assigned: zeev (profile)
Status: Closed Package: Other
PHP Version: 3.0b6 OS: Linux 2.1,glibc2
Private report: No CVE-ID: None
 [1998-03-06 09:08 UTC] short at ucw dot cz
function bug() { $a["a"]="1"; $a["b"]="2"; $a["c"]="3"; /*>>>*/ unset($a["b"]);
for (reset($a);current($a);next($a)) print current($a); }
Previous function outputs only "1" but IMHO should "13".
Note - { print $a["c"]; } still outputs "3"!

P.S.: Current version is still pretty buggy - SEGV quite often but only randomly. :-(

Compiled with apache-1.2.5-ssl and Postgres95.


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [1998-03-21 06:36 UTC] zeev
Unsetting an array element doesn't completely erase it.
I'll fix next() so that it works properly, but that loop
is bad anyway, as it doesn't handle arrays with empty

count()/each()/next()/prev()/reset()/end() were patched
to walk around this implementation side effect.  Users
should no longer be able to notice it, even though it'll
be fixed the Right Way(tm) on 3.1 only.

PHP Copyright © 2001-2022 The PHP Group
All rights reserved.
Last updated: Tue Nov 29 15:05:53 2022 UTC