What is the best way to check if an array is recursive in PHP ?
Given the following code:
I believe you can't check that. Read the ReferenceDoc for more information on reference.
Here is the function to check for RECURSION (from PHP doc comments), altough it seems to be very slow (I would not suggest it):
function is_array_reference ($arr, $key) {
$isRef = false;
ob_start();
var_dump($arr);
if (strpos(preg_replace("/[ \n\r]*/i", "", preg_replace("/( ){4,}.*(\n\r)*/i", "", ob_get_contents())), "[" . $key . "]=>&") !== false)
$isRef = true;
ob_end_clean();
return $isRef;
}