Forum Moderators: coopster
I found out that using arrays u can compare records in php..and that the no of records can be checked using the
"foreach" function
How do i start...?
I am clueless
function compare($array1, $comparison, $array2){
if(count($array1)!= count($array2)) return false;
foreach($array1 as $name => $value){
if(eval($array1[$name]." ".$comparison." ".$array2[$name])) $output[$name] = 1; else $output[$name] = 0;
}
return $output;
}$a = array("1", "2", "1", "2");
$b = array("0", "1", "2", "3");
$greater = compare($a, ">", $b);//returns an array 0, 0, 1, 1
Hope this helps;
But remember this works on association, not on order. And both arrays need to be the same length. Also you should check if $comparison is not sth malicious
Best regards
Michal Cibor