<?php
function
Program(
$value1
,
$value2
,
$arr
)
{
foreach
(
$arr
as
$val
) {
echo
$val
(
$value1
,
$value2
) .
"\n"
;
}
}
$f1
= '
if
(
$a
>= 0) {
return
"b * a^2 = "
.
$b
* sqrt(
$a
);}
else
{
return
false; }';
$f2
=
"return \"min(a, b) = \".min(\$a, \$b);"
;
$farr
=
array
(
create_function(
'$x, $y'
, '
return
"a hypotenuse: "
.sqrt(
$x
*
$x
+
$y
*
$y
);'),
create_function(
'$a, $b'
,
$f1
),
create_function(
'$a, $b'
,
$f2
)
);
echo
"first array of anonymous functions"
.
"\nParameter is a = 2 and b = 3\n"
;
Program(2, 3,
$farr
);
$sarr
=
array
(
create_function(
'$a, $b'
, '
return
"Lower case : "
.
strtolower
(
$a
) ;'),
create_function(
'$a, $b'
, '
return
"Similar Character : "
.
similar_text(
$a
,
$b
,
$percent
);')
);
echo
"\nSecond array of anonymous functions"
.
"\nParameter is a = GeeksForGeeks and"
.
"b = GeeksForGeeks\n"
;
Program(
"GeeksForGeeks"
,
"GeeksForGeeks"
,
$sarr
);
?>