<code><span>$condition</span>[<span>'is_own'</span>] = <span>0</span>; <span>$condition</span>[<span>'is_pass'</span>] = <span>0</span>; <span>$notDeal_user_list</span> = <span>array</span>(); <span>foreach</span>(<span>$temp</span><span>as</span><span>$k</span>=><span>$v</span>){ <span>$condition</span>[<span>'route_id'</span>] = <span>$v</span>[<span>'route_id'</span>]; <span>$temp_array</span> = <span>$route_person_model</span>->where(<span>$condition</span>)->field(<span>'user_id,route_id,id'</span>)->select(); <span>if</span>(!<span>empty</span>(<span>$temp_array</span>)){ <span>$notDeal_user_list</span> = array_merge(<span>$notDeal_user_list</span>,<span>$temp_array</span>); } <span>//array_merge函数 在其中一个为空的时候最后结果为空</span><span>//把不同行程的用户信息都拼接起来</span> } <span>// var_dump($notDeal_user_list); die();</span><span>foreach</span>(<span>$notDeal_user_list</span><span>as</span><span>$k</span>=><span>$v</span>){ <span>$notDeal_user_list</span>[<span>$k</span>][<span>'route_info'</span>] = getRouteInfo(<span>$v</span>[<span>'route_id'</span>]); <span>$notDeal_user_list</span>[<span>$k</span>][<span>'user_info'</span>] = getUserInfo(<span>$v</span>[<span>'user_id'</span>]); } <span>$this</span>->notDeal_user_list = <span>$notDeal_user_list</span>;</code>
在没有加if判断是否为空之前,数组整个都是null,加了之后就OK了。
这个拼接函数在其中一个为空的时候,会整体为空,需要做拼接的判断!
以上就介绍了array_merge 函数的使用,包括了方面的内容,希望对PHP教程有兴趣的朋友有所帮助。

ThesecrettokeepingaPHP-poweredwebsiterunningsmoothlyunderheavyloadinvolvesseveralkeystrategies:1)ImplementopcodecachingwithOPcachetoreducescriptexecutiontime,2)UsedatabasequerycachingwithRedistolessendatabaseload,3)LeverageCDNslikeCloudflareforservin

You should care about DependencyInjection(DI) because it makes your code clearer and easier to maintain. 1) DI makes it more modular by decoupling classes, 2) improves the convenience of testing and code flexibility, 3) Use DI containers to manage complex dependencies, but pay attention to performance impact and circular dependencies, 4) The best practice is to rely on abstract interfaces to achieve loose coupling.

Yes,optimizingaPHPapplicationispossibleandessential.1)ImplementcachingusingAPCutoreducedatabaseload.2)Optimizedatabaseswithindexing,efficientqueries,andconnectionpooling.3)Enhancecodewithbuilt-infunctions,avoidingglobalvariables,andusingopcodecaching

ThekeystrategiestosignificantlyboostPHPapplicationperformanceare:1)UseopcodecachinglikeOPcachetoreduceexecutiontime,2)Optimizedatabaseinteractionswithpreparedstatementsandproperindexing,3)ConfigurewebserverslikeNginxwithPHP-FPMforbetterperformance,4)

APHPDependencyInjectionContainerisatoolthatmanagesclassdependencies,enhancingcodemodularity,testability,andmaintainability.Itactsasacentralhubforcreatingandinjectingdependencies,thusreducingtightcouplingandeasingunittesting.

Select DependencyInjection (DI) for large applications, ServiceLocator is suitable for small projects or prototypes. 1) DI improves the testability and modularity of the code through constructor injection. 2) ServiceLocator obtains services through center registration, which is convenient but may lead to an increase in code coupling.

PHPapplicationscanbeoptimizedforspeedandefficiencyby:1)enablingopcacheinphp.ini,2)usingpreparedstatementswithPDOfordatabasequeries,3)replacingloopswitharray_filterandarray_mapfordataprocessing,4)configuringNginxasareverseproxy,5)implementingcachingwi

PHPemailvalidationinvolvesthreesteps:1)Formatvalidationusingregularexpressionstochecktheemailformat;2)DNSvalidationtoensurethedomainhasavalidMXrecord;3)SMTPvalidation,themostthoroughmethod,whichchecksifthemailboxexistsbyconnectingtotheSMTPserver.Impl


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

Notepad++7.3.1
Easy-to-use and free code editor

SAP NetWeaver Server Adapter for Eclipse
Integrate Eclipse with SAP NetWeaver application server.

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

PhpStorm Mac version
The latest (2018.2.1) professional PHP integrated development tool
