php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #15268 remove a 2 dimension array and the problem on array count
Submitted: 2002-01-29 00:33 UTC Modified: 2002-01-29 01:13 UTC
From: desaloo at yahoo dot com Assigned:
Status: Not a bug Package: Arrays related
PHP Version: 4.0.6 OS: window NT
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: desaloo at yahoo dot com
New email:
PHP Version: OS:

 

 [2002-01-29 00:33 UTC] desaloo at yahoo dot com
hello :
  i have a problem on remove 2 dimension array in which the count of array still is same as before the array was remove.

example:
  $e[0][0] = "aaa";
  $e[0][1] = "bbb";
  $e[1][0] = "111";
  $e[1][1] = "222";
  
  count(array) is equal to 2, then i try to remove an element of that array using unset :
  unset($e[1][0]);
  unset($e[1][1]);

 then i try to retrieve the count of array again, the result should be 1, but what i get from it is the count of the array is still not change, which it :
  echo count($e);    //result is 2

i have been try this for single dimension array, there is no such problem on it, just the 2 dimension array will face this kind of problem.

thank you !!

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-01-29 01:13 UTC] georg@php.net
In your sample you removed 2nd dimensions from $e, not 
first, so $e[1] is an empty array.

e.g. vardump($e):
array(2) { [0]=> array(2) { [0]=> string(3) "aaa" [1]=> 
string(3) "bbb" } [1]=> array(0) { } }

To remove first dimension use unset($e[1])

Regards

Georg

 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Mar 29 04:01:29 2024 UTC