这是xml的文件部分内容,就是从里面一个一个的取出value标签后面的值,最好还能得知有几个record。
就是可以应用到自己定义的函数里面,比如
function value($a,$b,$c,$d,$n){
.......
}
for(i=1;i value($a,$b,$c,$d,$i);
}
循环次数:
第一次实现value(13.82,13.94,13.79,13.85,1)
第二次实现value(13.82,13.86,13.58,13.60,2)
回复讨论(解决方案)
不一定需要正则表达式,只要能获取xml的数据,能够使用到函数里面就可以的。。谢谢各位大神了!
php 提供了专用方法
$s =<<< XML<Record><Item Id="1"><Value>20110524</Value></Item><Item Id="7"><Value>13.82</Value></Item><Item Id="8"><Value>13.94</Value></Item><Item Id="9"><Value>13.79</Value></Item><Item Id="11"><Value>13.85</Value></Item></Record><Record><Item Id="1"><Value>20110525</Value></Item><Item Id="7"><Value>13.82</Value></Item><Item Id="8"><Value>13.86</Value></Item><Item Id="9"><Value>13.58</Value></Item><Item Id="11"><Value>13.60</Value></Item></Record>XML;$x = simplexml_load_string("<root>$s</root>");foreach($x->Record as $node) { $t = array(); foreach($node->Item as $v) $t[] = current($v->Value); print_r($t);}
Array( [0] => 20110524 [1] => 13.82 [2] => 13.94 [3] => 13.79 [4] => 13.85)Array( [0] => 20110525 [1] => 13.82 [2] => 13.86 [3] => 13.58 [4] => 13.60)
$count=preg_match_all('/<Record>(.+?)<\/Record>/is',$str,$m);echo $count;preg_match_all('/<Value>(.+?)<\/Value>/is',$str,$values);echo "<pre class="brush:php;toolbar:false">";print_r($values[1]);echo "";/*2Array( [0] => 20110524 [1] => 13.82 [2] => 13.94 [3] => 13.79 [4] => 13.85 [5] => 20110525 [6] => 13.82 [7] => 13.86 [8] => 13.58 [9] => 13.60)*/
谢谢楼上的两位大神,问题按照你们的方法已经解决了~~嘿嘿

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

SublimeText3 Linux new version
SublimeText3 Linux latest version

MantisBT
Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

Zend Studio 13.0.1
Powerful PHP integrated development environment

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

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