<?php
$test_data1 = array('one','two','three');
// all is ok
$test_data2 = array(array('one','two','three'));
// windows error:
// #The instruction at '<address>' referenced memory at '<address>'.
// #The memory could not be read.
// #Click OK to terminate the program.
// No error shows up in console, sometimes script stops without error but sometimes executes like nothing is happening.
$test_data3 = array(array('one','two','three'),array('four','five','six'));
// error in PHP console:
// Fatal error: Call to a member function show_message() on a non-object in c:\scripts\found-error.php on line xx
// values one two three are displayed, four five and six are ommitted.
class myClass {
function iterate_multidim_array($array) {
array_walk_recursive($array,function(&$val,$key,&$obj) {
$obj->show_message($val);
},$this);
}
function show_message($msg) {
echo $msg."\n";
}
}
echo phpversion()."\n\n";
$myInstance = new MyClass();
$myInstance-> iterate_multidim_array($test_data3);
?>