I'd like my function to have a comparison operator as an argument (or preferably, as part of an argument such as >0 ):
Instead of
function comps($a,$b){
if ($a > $b)
echo "This works.";
}
comps(1,0);
I'd like to be able to do something like
function comps($a,$b){
if ($a $b)
echo "This works.";
}
comps(1,'>0');
I've been banging my head agains the wall on this for a while. I've tried different iterations of:
"/>0"
'>' . 0
(string)> 0
as well as trying the comparison operator as a third argument.
Actual use is:
function mysort($key,$match){
$temp_array = array();
global $students;
foreach ($students as $row) {
if($row[$key] > $match )
$temp_array[]= $row;
}
foreach ($temp_array as $row) {
echo $row['email'] . ', ';
}
}
mysort('suzuki', '0');
Thanks