I'm fairly new to php and i have problem with loops. I have a foreach loop,
foreach ($contents as $g => $f)
{
p($f);
}
which gives some arrays, depending on how many contents i have. currently i have 2,
Array
(
[quantity] => 1
[discount] => 1
[discount_id] => 0
[id] => 1506
[cat_id] => 160
[price] => 89
[title] => კაბა
)
Array
(
[quantity] => 1
[discount] => 1
[discount_id] => 0
[id] => 1561
[cat_id] => 160
[price] => 79
[title] => ზედა
)
my goal is to save the array which has the max price in it as a different variable. I'm kinda stuck on how to do that, i managed to find the max price with the max()
function like so
foreach ($contents as $g => $f)
{
$priceprod[] = $f['price'];
$maxprice = max($priceprod);
p($maxprice);
}
but i still dont get how i'm supposed to find out in which array is the max price. any suggestions would be appreciated