php.net |  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
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem:
47 - 45 = ?
Subscribe to this entry?

 
 [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.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

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
elements.

--
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-2024 The PHP Group
All rights reserved.
Last updated: Mon Jun 03 04:01:31 2024 UTC