|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #14920 Internal pointer stack for arrays, to solve pointer problems
Submitted: 2002-01-07 17:13 UTC Modified: 2011-01-01 00:13 UTC
Avg. Score:5.0 ± 0.0
Reproduced:2 of 2 (100.0%)
Same Version:1 (50.0%)
Same OS:2 (100.0%)
From: paule at cs dot tamu dot edu Assigned:
Status: Wont fix Package: Arrays related
PHP Version: 4.1.1 OS: All
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Bug Type:
From: paule at cs dot tamu dot edu
New email:
PHP Version: OS:


 [2002-01-07 17:13 UTC] paule at cs dot tamu dot edu
There are many occasions where an array's internal pointer gets modifed by a function that requires a traversal for one reason or another (e.g., foreach, array_walk, etc.). This often messes with the continuity and readability of the code. For example, some sort of a workaround is required if one wants to nest a foreach statement within another operating on the same array. Often these workarounds involve various traversals or copy operations and can cause serious performance issues with larger array.

A simple solution for this is to provide for an internal pointer stack. I propose two functions:

void pos_push(array array);
mixed pos_pop(array array);

The function pos_push merely pushes the internal pointer position onto the pointer stack. The complementary function pos_pop pops the internal pointer off of the stack and returns the resulting current value of the new position in the array.

This is easy to efficiently implement through a linked list stack specific to each array. The memory usage is minimal, and overhead is slight. The stack could store the actual position pointers. Of course, that means care would have to be taken if an element that was been stored on the stack was deleted.


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2011-01-01 00:13 UTC]
-Status: Open +Status: Wont fix -Package: Feature/Change Request +Package: Arrays related
PHP Copyright © 2001-2023 The PHP Group
All rights reserved.
Last updated: Tue Jun 06 03:03:42 2023 UTC