|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #17279 array_recurse_safe()
Submitted: 2002-05-16 18:09 UTC Modified: 2013-07-12 13:20 UTC
Avg. Score:3.5 ± 1.5
Reproduced:2 of 2 (100.0%)
Same Version:1 (50.0%)
Same OS:1 (50.0%)
From: tomat at lenderlabdot dot com Assigned:
Status: Wont fix Package: *General Issues
PHP Version: 4.1.2 OS: All
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2002-05-16 18:09 UTC] tomat at lenderlabdot dot com
Will solve problems like:

This code doesn't work, but I don't know enough C to write it right.  It would work if PHP had a method for determining if two variables are the same reference. (unless there is one that I haven't found...)


function array_recurse_safe($array, $parents=array()) {
    foreach($array as $element) {
        if(is_array($element) || is_object($element)) {
            foreach($parents as $parent) {
                if(&$parent == &$element) {
            if(!$loop) {
                $element=array_recurse_safe($element, $parents);
    return $array;

Also, the usage of unset() is improper here, but I left it in for simplicity.


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2013-07-12 13:20 UTC]
-Status: Open +Status: Wont fix -Package: Feature/Change Request +Package: *General Issues
 [2013-07-12 13:20 UTC]
Related issue already fixed this problem.
PHP Copyright © 2001-2022 The PHP Group
All rights reserved.
Last updated: Sat Aug 13 22:05:44 2022 UTC