i noticed a wired behavior of php when doing something like
the code below is trying to loop through all arrays in multiarray, and it it should return $n when it is not an array anymore.
basicly a counter for dimentions.
<?php
//some random values multiarray
$arrays[1][2][3][5] = '1';
$arrays[1][2][3] = '1';
$arrays[1][2][3][4] = '1';
$arrays[3][6][3][1][5] = '2';
function second_func($array, $n)//adding $n then returning to 1st func
{
$n++;
first_func($array, $n);
}
function first_func($arrays, $n = 0)//checking if array then 2nd func, if not then return.
{
if(is_array($arrays))
{
foreach($arrays as $array)second_func($array, $n);
}else
{
echo $n; //working
return $n; //not working
};
}
$result[] = first_func($arrays);
print_r($result);//nothing here
or any similar actions, if i put file_put_contents inside 1st function, then the result will be different with each refresh, and the function cannot be returned just as it is, only echoing it works stable.
I remember i had a similar 2 function to delete cache files and ended up with clean hard drive, or a similar func to create file and i would have files in random folders over hd.
didnt check for similar quastions, cannot formulate the quastion right..