$a=2;
$b=6;
$c=7;
$r1=8;
$r2=9;
$r3=6;
$array = array(
array('MIDDAY'=>$a,'RATE'=>$r1),
array('SHORTDAY'=>$b,'RATE'=>$r2),
array('LONGDAY'=>$c,'RATE'=>$r3)
);
I have a array like this and i want this array to process
and want to check whose count is greater like as above LONGDAY=7
then i want this LONGDAY key in one variable and its RATE in other variable
And also want to check if two count is equal then like LONGDAY=7 and MIDDAT=7
then i want to check with RATE whose rate is greater then same
i want this LONGDAY key in one variable and its RATE in other variable (for RATE is greater in this case)
Something along these lines should do it to sort the array according to your rules and take the top result.
Note, this uses PHP 5.3+ anonymous function syntax.