Hi,
Have been experimenting with the array_walk function and a little array debug print
facility, but ran into a
problem with nested functions. The code can be written with nested functions and
successfully executed once; but
when repeatedly executed an error appears.
Can one code user-defined functions nested within one another - and repeatedly execute
them?
The PHP Manual: Chapter 12. Functions, says:
"A function may be defined using syntax such as the following:
...
Any valid PHP code may appear inside a function, even other
functions and class definitions."
Here is some test-bed code:
<?php
Function ShowList( $title, $aList )
{
Function FnNested( $item, $key )
{
echo "<br>$key=" . $item . "~";
} //end of FnNested
echo "<br>Listing array=$title: n=" . count( $aList );
array_walk( $aList, "FnNested" );
} //end of function ShowList
//mainline code
$aLocated = array( 'zero', 'one', 'two', 'three' );
ShowList( "Located1", $aLocated );
ShowList( "Located2", $aLocated );
?>
Sample output:
FnShowList~
Listing array=Located1: n=4
0=zero~
1=one~
2=two~
3=three~
FnShowList~
Fatal error: Cannot redeclare fnnested() in c:\data\webs\webute_tst\l.php on line 6
Please advise,
=dn
WinNT 4.0 SP6a running PHP vn 4.0.6, Apache vn 1.3.20WinNT, MySQL vn 3.23.40-nt
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php