用我这种方法写数组太麻烦了,请高手指教一下
我今天临时学的PHP,大家别笑话我。。。
下面这段代码用多维数组怎么写呢?或者什么循环之类的,目前用我这种方法,要是有一百集的话,我就要写到一百,虽然可以用的,但是相当麻烦,谁能帮我精简一下,多谢啦!。
<?php<br />$str='bdhd://200901671|D772D8E1024F0FD8E0824B0EA780232E|幸福摩天轮[DVD国语]01.rmvb<br />bdhd://291075915|D522381AF3E6F7E0F563AD4EFA10D0CE|幸福摩天轮国语版02.rmvb<br />bdhd://298891909|497E7DED0EBFDAA6A8FAB4090F188F5E|幸福摩天轮国语版03.rmvb<br />bdhd://301745786|E81EF94B221952ABA26364AC5DA84B67|幸福摩天轮国语版04.rmvb<br />bdhd://176465436|40F28A77D5EED5C5B7DDF3A3AFADC15C|幸福摩天轮国语版05.rmvb<br />bdhd://300390984|ACEA3118EB814D9167DF0F27289E82D6|幸福摩天轮国语版06.rmvb<br />bdhd://298343800|C9CCF7BA67F7DA14D754A992DD8F6A37|幸福摩天轮国语版07.rmvb<br />bdhd://200661628|281605707686E6E57E6C08FC28314B22|幸福摩天轮[DVD国语]08.rmvb<br />bdhd://201050238|CDAEC0AD4A6F7A4748C18C305D4D832D|幸福摩天轮[DVD国语]09.rmvb<br />bdhd://192036005|7DA1F0052A9AF2D69C8132EF9F9C0EAD|幸福摩天轮国语版10.rmvb <br />bdhd://192961337|35921C5F22111A5AA9A39CCC26AB75B6|幸福摩天轮国语版11.rmvb <br />bdhd://282339636|7743DB068D199F2E6EB921BBAEE99FBF|幸福摩天轮国语版12.rmvb<br />bdhd://326028524|6893BB04B5C76D8396611376ED5253CE|幸福摩天轮粤语13.HDTV.mp4<br />bdhd://329388655|A0723D41A65E44F2A5EE8CC2DFDF4F23|幸福摩天轮粤语14_HDTV.mp4';<br />$exp=explode("\r\n",$str);<br />$a0=$exp[0];<br />$a1=$exp[1];<br />$a2=$exp[2];<br />$a3=$exp[3]; <br />$a4=$exp[4];<br />$a5=$exp[5];<br />$a6=$exp[6];<br />$a7=$exp[7];<br />$a8=$exp[8];<br />$a9=$exp[9];<br />$a10=$exp[10];<br />$a11=$exp[11];<br />$a12=$exp[12];<br />$a13=$exp[13];<br />$a14=$exp[14];<br />$a15=$exp[15];<br />$a16=$exp[16];<br />$a17=$exp[17];<br />$a18=$exp[18];<br />$a19=$exp[19];<br />$a20=$exp[20];<br />$a21=$exp[21];<br />$a22=$exp[22];<br />$a23=$exp[23];<br />$a24=$exp[24];<br />$a25=$exp[25];<br />$a26=$exp[26];<br />$a27=$exp[27];<br />$a28=$exp[28];<br />$a29=$exp[29];<br />$a30=$exp[30];<br />$a31=$exp[31];<br />$a32=$exp[32];<br />$a33=$exp[33];<br />$a34=$exp[34];<br />$a35=$exp[35];<br />$a36=$exp[36];<br />$a37=$exp[37];<br />$a38=$exp[38];<br />$a39=$exp[39];<br />$a40=$exp[40];<br />$a41=$exp[41];<br />$a42=$exp[42];<br />$a43=$exp[43];<br />$a44=$exp[44];<br />$a45=$exp[45];<br />$a46=$exp[46];<br />$a47=$exp[47];<br />$a48=$exp[48];<br />if(empty($a0)) echo "";<br />else<br />echo '<a href="'.$a0.'" target=_blank>第一集</a>';<br />if(empty($a1)) echo "";<br />else<br />echo '<a href="'.$a1.'" target=_blank>第二集</a>';<br />if(empty($a2)) echo "";<br />else<br />echo '<a href="'.$a2.'" target=_blank>第三集</a>';<br />if(empty($a3)) echo "";<br />else<br />echo '<a href="'.$a3.'" target=_blank>第四集</a>';<br />if(empty($a4)) echo "";<br />else<br />echo '<a href="'.$a4.'" target=_blank>第五集</a>';<br />if(empty($a5)) echo "";<br />else<br />echo '<a href="'.$a5.'" target=_blank>第六集</a>';<br />if(empty($a6)) echo "";<br />else<br />echo '<a href="'.$a6.'" target=_blank>第七集</a>';<br />if(empty($a7)) echo "";<br />else<br />echo '<a href="'.$a7.'" target=_blank>第八集</a>';<br />if(empty($a8)) echo "";<br />else<br />echo '<a href="'.$a8.'" target=_blank>第九集</a>';<br />if(empty($a9)) echo "";<br />else<br />echo '<a href="'.$a9.'" target=_blank>第十集</a>';<br />if(empty($a10)) echo "";<br />else<br />echo '<a href="'.$a10.'" target=_blank>第十集</a>';<br />?><br />
------解决方案--------------------
<br>// 上接 $str="...";<br>$exp=explode("\n",$str);<br><br>// 把数字序号转换为中文表示比较麻烦,而且不利效率。如果没影响,你可以不用这个功能。<br>function num2str($num)<br>{<br> $cns = array('零', '一', '二', '三', '四', '五', '六', '七', '八', '九', '十'<div class="clear"> </div>

TomakePHPapplicationsfaster,followthesesteps:1)UseOpcodeCachinglikeOPcachetostoreprecompiledscriptbytecode.2)MinimizeDatabaseQueriesbyusingquerycachingandefficientindexing.3)LeveragePHP7 Featuresforbettercodeefficiency.4)ImplementCachingStrategiessuc

ToimprovePHPapplicationspeed,followthesesteps:1)EnableopcodecachingwithAPCutoreducescriptexecutiontime.2)ImplementdatabasequerycachingusingPDOtominimizedatabasehits.3)UseHTTP/2tomultiplexrequestsandreduceconnectionoverhead.4)Limitsessionusagebyclosin

Dependency injection (DI) significantly improves the testability of PHP code by explicitly transitive dependencies. 1) DI decoupling classes and specific implementations make testing and maintenance more flexible. 2) Among the three types, the constructor injects explicit expression dependencies to keep the state consistent. 3) Use DI containers to manage complex dependencies to improve code quality and development efficiency.

DatabasequeryoptimizationinPHPinvolvesseveralstrategiestoenhanceperformance.1)Selectonlynecessarycolumnstoreducedatatransfer.2)Useindexingtospeedupdataretrieval.3)Implementquerycachingtostoreresultsoffrequentqueries.4)Utilizepreparedstatementsforeffi

PHPisusedforsendingemailsduetoitsbuilt-inmail()functionandsupportivelibrarieslikePHPMailerandSwiftMailer.1)Usethemail()functionforbasicemails,butithaslimitations.2)EmployPHPMailerforadvancedfeatureslikeHTMLemailsandattachments.3)Improvedeliverability

PHP performance bottlenecks can be solved through the following steps: 1) Use Xdebug or Blackfire for performance analysis to find out the problem; 2) Optimize database queries and use caches, such as APCu; 3) Use efficient functions such as array_filter to optimize array operations; 4) Configure OPcache for bytecode cache; 5) Optimize the front-end, such as reducing HTTP requests and optimizing pictures; 6) Continuously monitor and optimize performance. Through these methods, the performance of PHP applications can be significantly improved.

DependencyInjection(DI)inPHPisadesignpatternthatmanagesandreducesclassdependencies,enhancingcodemodularity,testability,andmaintainability.Itallowspassingdependencieslikedatabaseconnectionstoclassesasparameters,facilitatingeasiertestingandscalability.

CachingimprovesPHPperformancebystoringresultsofcomputationsorqueriesforquickretrieval,reducingserverloadandenhancingresponsetimes.Effectivestrategiesinclude:1)Opcodecaching,whichstorescompiledPHPscriptsinmemorytoskipcompilation;2)DatacachingusingMemc


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

SublimeText3 English version
Recommended: Win version, supports code prompts!

Safe Exam Browser
Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

SecLists
SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

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

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