I'm trying to refine a search list so that when a user clicks on checkboxes it refines the results based on the criteria selected. Here is the PHP function I'm using:
function($criteria_a,$criteria_b,$criteria_c,$criteria_d){
if($criteria_a==1){
// build array
$a_array=array($user_a,$user_e,$user_f);
}
if($criteria_b==1){
// build array
$b_array=array($user_a,$user_c,$user_e);
}
if($criteria_c==1){
// build array
$c_array=array($user_b);
}
if($criteria_d==1){
// build array
$d_array=array($user_a,$user_e);
}
$main_array = array_merge($a_array,$b_array,$c_array,$d_array);
}
Basically, when a user clicks on the criteria A checkbox (which could be something like 'Show those under 30') it builds up $a_array with a list of the users that meet the criteria.
But the problem is this: if I specified criteria A, B and D as 1, it fills the $main_array with users who meet any of the criteria instead of users who meet all the criteria. The main array would look like this:
array($user_a,$user_e,$user_f,$user_a,$user_c,$user_e,$user_a,$user_e);
But I only want it to list the users that meet all the criteria:
array($user_a,$user_e);
These users meet each of the criteria being specified instead of any of the criteria being specified. I'm also not sure if this helps:
$acv = array_count_values($main_array);
arsort($acv);
$main_array = array_keys($acv);
Does anybody know what I can do?