November 14, 2017 Anonymous function example in PHP Code Block <?php /*** An array function to work with its individual value whatever we want.* @param array $array* @param function $function*/function anonymous_test($array, $function){ foreach ($array as $single){ $function($single); }}?> Code Block <?php/*** Here we are writing a function which will print only if it's printable.*/$arr = [1,2,3,['A','B'],4,5];anonymous_test($arr, function($value){ if(!is_array($value) && !is_object($value)){ echo $value; }}); Posted in Algorithm, Function, PHP by ahmadasjad Leave a comment