note 73936 deleted from language.types.array by peehaa
| From: | peehaa@php.net | Date: | Sun, 28 Apr 2019 10:25:00 +0000 |
| Subject: | note 73936 deleted from language.types.array by peehaa | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-210777@lists.php.net to get a copy of this message | ||
Note Submitter: Spudley
----
On array recursion...
Given the following code:
<?php
$myarray = array('test',123);
$myarray[] = &$myarray;
print_r($myarray);
?>
The print_r() will display *RECURSION* when it gets to the third element of the array.
There doesn't appear to be any other way to scan an array for recursive references, so if you
need to check for them, you'll have to use print_r() with its second parameter to capture the
output and look for the word *RECURSION*.
It's not an elegant solution, but it's the only one I've found, so I hope it helps
someone.