-2

I have an array like this:

$sim = array( 
    array( 
        word => "happy", 
        percent => 100,
    ),
);

And I want to search the word with highest percent in my array.

dhh
  • 4,289
  • 8
  • 42
  • 59
barney
  • 59
  • 1
  • 7

1 Answers1

0
$max = -9999999; //will hold max val
$found_item = null; //will hold item with max val;
foreach($arr as $k=>$v)
{
    if($v['Total']>$max)
    {
        $max = $v['Total'];
        $found_item = $v;
    }
}
echo "max value is $max";
print_r($found_item);

Working demo

Muhammad Usman
  • 345
  • 1
  • 11