Evaluate the maximum value array in a multi-dimensional array as follows:
Array
(
[0] => Array
(
[CampaignID] = & gt; 2304111
[ExistStatus] => 2
[CampaignName] => July Sales Promotion Center
[CampaignType] => targeted promotion plan
[AvgCommission] = & gt; 1.71%
[Exist] => 1
[ShopKeeperID] = & gt; 18791530
[Properties] => No
)
[1] => Array
(
[CampaignID] = & gt; 2979322
[CampaignName] => New Year promotional price
[CampaignType] => targeted promotion plan
[AvgCommission] = & gt; 4.90%
[Exist] =>
[ShopKeeperID] = & gt; 18791530
[Properties] => No
)
[2] => Array
(
[CampaignID] = & gt; 7275933
[CampaignName] => Thanks
[CampaignType] => targeted promotion plan
[AvgCommission] = & gt; 1.53%
[Exist] =>
[ShopKeeperID] = & gt; 18791530
[Properties] => No
)
)
Find out if AvgCommission is the maximum value, and add the CampaignID
Display the result as array (2979322, 4.9 );
My algorithm is too bad. I cannot understand it when I find many algorithms !!!
Reply to discussion (solution)
foreach($arr as $v) $r[] = $v['AvgCommission'];array_multisort($r, SORT_DESC, SORT_NUMERIC, $arr);$r = array($arr[0]['CampaignID'], $arr[0]['AvgCommission'] + 0);print_r($r);
You are the God of God
That is not necessarily the case. Such a combination of code is a regular expression, so you will be proficient in getting started.
For database queries
SELECT CampaignID, AvgCommission FROM tbl_name order by AvgCommission DESC
You must be familiar
In fact, they correspond one by one.
Thank you, God. I feel a little clear!