数组是这样的:
Array
(
[0] => Array
(
[CampaignID] => 2304111
[ExistStatus] => 2
[CampaignName] => 7月促销中心
[CampaignType] => 定向推广计划
[AvgCommission] => 1.71 %
[Exist] => 1
[ShopKeeperID] => 18791530
[Properties] => 否
)
[1] => Array
(
[CampaignID] => 2979322
[CampaignName] => 新年 促销价
[CampaignType] => 定向推广计划
[AvgCommission] => 4.90 %
[Exist] =>
[ShopKeeperID] => 18791530
[Properties] => 否
)
[2] => Array
(
[CampaignID] => 7275933
[CampaignName] => 感恩
[CampaignType] => 定向推广计划
[AvgCommission] => 1.53 %
[Exist] =>
[ShopKeeperID] => 18791530
[Properties] => 否
)
)
找出AvgCommission为最大值的,同时还要带上CampaignID
让结果显示为array(2979322,4.9);
我算法太差了,找了好多都看不明白!!!
回复讨论(解决方案)
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);
你就是额的神
那也未必,这样的代码组合是定式,多接触就熟练了
如果是数据库查询,那么
SELECT CampaignID, AvgCommission FROM tbl_name ORDER BY AvgCommission DESC
你一定不陌生
其实他们是一一对应的
谢谢神,感觉明白了些了!

ThebestapproachforsendingemailsinPHPisusingthePHPMailerlibraryduetoitsreliability,featurerichness,andeaseofuse.PHPMailersupportsSMTP,providesdetailederrorhandling,allowssendingHTMLandplaintextemails,supportsattachments,andenhancessecurity.Foroptimalu

The reason for using Dependency Injection (DI) is that it promotes loose coupling, testability, and maintainability of the code. 1) Use constructor to inject dependencies, 2) Avoid using service locators, 3) Use dependency injection containers to manage dependencies, 4) Improve testability through injecting dependencies, 5) Avoid over-injection dependencies, 6) Consider the impact of DI on performance.

PHPperformancetuningiscrucialbecauseitenhancesspeedandefficiency,whicharevitalforwebapplications.1)CachingwithAPCureducesdatabaseloadandimprovesresponsetimes.2)Optimizingdatabasequeriesbyselectingnecessarycolumnsandusingindexingspeedsupdataretrieval.

ThebestpracticesforsendingemailssecurelyinPHPinclude:1)UsingsecureconfigurationswithSMTPandSTARTTLSencryption,2)Validatingandsanitizinginputstopreventinjectionattacks,3)EncryptingsensitivedatawithinemailsusingOpenSSL,4)Properlyhandlingemailheaderstoa

TooptimizePHPapplicationsforperformance,usecaching,databaseoptimization,opcodecaching,andserverconfiguration.1)ImplementcachingwithAPCutoreducedatafetchtimes.2)Optimizedatabasesbyindexing,balancingreadandwriteoperations.3)EnableOPcachetoavoidrecompil

DependencyinjectioninPHPisadesignpatternthatenhancesflexibility,testability,andmaintainabilitybyprovidingexternaldependenciestoclasses.Itallowsforloosecoupling,easiertestingthroughmocking,andmodulardesign,butrequirescarefulstructuringtoavoidover-inje

PHP performance optimization can be achieved through the following steps: 1) use require_once or include_once on the top of the script to reduce the number of file loads; 2) use preprocessing statements and batch processing to reduce the number of database queries; 3) configure OPcache for opcode cache; 4) enable and configure PHP-FPM optimization process management; 5) use CDN to distribute static resources; 6) use Xdebug or Blackfire for code performance analysis; 7) select efficient data structures such as arrays; 8) write modular code for optimization execution.

OpcodecachingsignificantlyimprovesPHPperformancebycachingcompiledcode,reducingserverloadandresponsetimes.1)ItstorescompiledPHPcodeinmemory,bypassingparsingandcompiling.2)UseOPcachebysettingparametersinphp.ini,likememoryconsumptionandscriptlimits.3)Ad


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Atom editor mac version download
The most popular open source editor

SublimeText3 Mac version
God-level code editing software (SublimeText3)

SublimeText3 Chinese version
Chinese version, very easy to use

SublimeText3 Linux new version
SublimeText3 Linux latest version

VSCode Windows 64-bit Download
A free and powerful IDE editor launched by Microsoft
