接收到类似下面一个xml文件,想把文件的内容分成对应的数组 输出出来,应该怎么处理
比如:
比如(最后得到类似的数据):
$isbn10="7507424758";
$pages="245";
<?xml version="1.0" encoding="UTF-8" ?> - <entry xmlns="http://www.w3.org/2005/Atom" xmlns:db="http://www.douban.com/xmlns/" xmlns:gd="http://schemas.google.com/g/2005" xmlns:openSearch="http://a9.com/-/spec/opensearchrss/1.0/" xmlns:opensearch="http://a9.com/-/spec/opensearchrss/1.0/"> <id>http://api.douban.com/book/subject/10506822</id> <title>我是个算命先生</title> <category scheme="http://www.douban.com/2007#kind" term="http://www.douban.com/2007#book" /> - <author> <name>易之</name> </author> <link href="http://api.douban.com/book/subject/10506822" rel="self" /> <link href="http://book.douban.com/subject/10506822/" rel="alternate" /> <link href="http://img3.douban.com/spic/s8993763.jpg" rel="image" /> <link href="http://m.douban.com/book/subject/10506822/" rel="mobile" /> <summary>《我是个算命先生》内容简介:算命这个行当,萌芽于先秦,发展于隋唐,泛滥于明清;汉代张良、三国诸葛亮、明代刘伯温,不同时期的代表人物,都在手相、面相、八字、八卦中辨认着人类的命运。祖爷,生于1902年,卒年不详,民国时期名震大江南北的算命群体“江相派”掌门人。《沪报》将他与袁树珊、韦千里、徐乐吾并称为“民国四大算命宗师”,所谓“南袁北韦东乐吾,三仙归来问祖爷”。祖爷15岁开始为人算命,每算必中,令人咋舌;而后叱咤江湖30多年,留下无数不可思议的神算传奇与悬念;乃至于中原大战之前,山西军阀阎锡山也三顾茅庐,终于求得祖爷一卦。祖爷总说,看的是面相,算的是八字,捕捉的是问卦人脸上不断闪烁的欲望:贪婪、虚荣、妒忌、恐惧、傲慢??人的命运,确实写在脸上。祖爷一生几乎从未失手,唯一没有算到的,却是他自己的命运;面对凄凉晚景,他认为是自己泄露了太多天机…… 翻开《我是个算命先生》,让一个82岁的算命老先生带您见识算命背后的古老智慧与江湖猫腻。 海报:</summary> <db:attribute name="isbn10">7507424758</db:attribute> <db:attribute name="isbn13">9787507424751</db:attribute> <db:attribute name="title">我是个算命先生</db:attribute> <db:attribute name="pages">245</db:attribute> <db:attribute name="author">易之</db:attribute> <db:attribute name="price">29.90元</db:attribute> <db:attribute name="publisher">中国城市出版社</db:attribute> <db:attribute name="binding">平装</db:attribute> <db:attribute name="pubdate">2012-2</db:attribute> <db:attribute name="author-intro">易之,男,山东即墨人。8岁接触道家学派,12岁跟随当地异人合玄师傅修习四柱,大学师从国内知名玄学教授段景莲。现为中华周易协会常务理事。</db:attribute> <db:tag count="585" name="算命" /> <db:tag count="463" name="小说" /> <db:tag count="197" name="骗局" /> <db:tag count="137" name="社会分析" /> <db:tag count="129" name="黑道学" /> <db:tag count="112" name="社会" /> <db:tag count="106" name="文化" /> <db:tag count="89" name="中国" /> <gd:rating average="7.0" max="10" min="0" numRaters="971" /> </entry>
回复讨论(解决方案)
前面有个大侠 给了一段代码:
preg_match_all('/>(.+)',$s,$m);
print_r($m[1]);
这段代码可以把我要的内容输出出来,我想的是把他对应起来。
$isbn10="7507424758";
$pages="245";
还有个问题 就是(类似
$s=<<<html<db:attribute name="isbn10">7507424758</db:attribute> <db:attribute name="isbn13">9787507424751</db:attribute> <db:attribute name="title">我是个算命先生</db:attribute> <db:attribute name="pages">245</db:attribute> <db:attribute name="author">易之</db:attribute> <db:attribute name="price">29.90元</db:attribute> <db:attribute name="publisher">中国城市出版社</db:attribute> <db:attribute name="binding">平装</db:attribute>html;preg_match_all('/(name="(.+)")?>(.+)</mU',$s,$m);extract(array_combine($m[2],$m[3]));var_dump($isbn10,$title);

TheSecretTokeEpingAphp-PowerEdwebSiterUnningSmoothlyShyunderHeavyLoadInVolvOLVOLVOLDEVERSALKEYSTRATICES:1)emplactopCodeCachingWithOpcachingWithOpCacheToreCescriptexecution Time,2)使用atabasequercachingCachingCachingWithRedataBasEndataBaseLeSendataBaseLoad,3)

你應該關心DependencyInjection(DI),因為它能讓你的代碼更清晰、更易維護。 1)DI通過解耦類,使其更模塊化,2)提高了測試的便捷性和代碼的靈活性,3)使用DI容器可以管理複雜的依賴關係,但要注意性能影響和循環依賴問題,4)最佳實踐是依賴於抽象接口,實現鬆散耦合。

是的,優化papplicationispossibleandessential.1)empartcachingingcachingusedapcutorediucedsatabaseload.2)優化的atabaseswithexing,高效Quereteries,and ConconnectionPooling.3)EnhanceCodeWithBuilt-unctions,避免使用,避免使用ingglobalalairaiables,並避免使用

theKeyStrategiestosigantificallyBoostPhpaPplicationPerformenCeare:1)UseOpCodeCachingLikeLikeLikeLikeLikeCacheToreDuceExecutiontime,2)優化AtabaseInteractionswithPreparedStateTementStatementStatementAndProperIndexing,3)配置

aphpdepentioncontiveContainerIsatoolThatManagesClassDeptions,增強codemodocultion,可驗證性和Maintainability.itactsasaceCentralHubForeatingingIndections,因此reducingTightCightTightCoupOulplingIndeSingantInting。

選擇DependencyInjection(DI)用於大型應用,ServiceLocator適合小型項目或原型。 1)DI通過構造函數注入依賴,提高代碼的測試性和模塊化。 2)ServiceLocator通過中心註冊獲取服務,方便但可能導致代碼耦合度增加。

phpapplicationscanbeoptimizedForsPeedAndeffificeby:1)啟用cacheInphp.ini,2)使用preparedStatatementSwithPdoforDatabasequesies,3)3)替換loopswitharray_filtaray_filteraray_maparray_mapfordataprocrocessing,4)conformentnginxasaseproxy,5)

phpemailvalidation invoLvesthreesteps:1)格式化進行regulareXpressecthemailFormat; 2)dnsvalidationtoshethedomainhasavalidmxrecord; 3)


熱AI工具

Undresser.AI Undress
人工智慧驅動的應用程序,用於創建逼真的裸體照片

AI Clothes Remover
用於從照片中去除衣服的線上人工智慧工具。

Undress AI Tool
免費脫衣圖片

Clothoff.io
AI脫衣器

Video Face Swap
使用我們完全免費的人工智慧換臉工具,輕鬆在任何影片中換臉!

熱門文章

熱工具

mPDF
mPDF是一個PHP庫,可以從UTF-8編碼的HTML產生PDF檔案。原作者Ian Back編寫mPDF以從他的網站上「即時」輸出PDF文件,並處理不同的語言。與原始腳本如HTML2FPDF相比,它的速度較慢,並且在使用Unicode字體時產生的檔案較大,但支援CSS樣式等,並進行了大量增強。支援幾乎所有語言,包括RTL(阿拉伯語和希伯來語)和CJK(中日韓)。支援嵌套的區塊級元素(如P、DIV),

SublimeText3漢化版
中文版,非常好用

WebStorm Mac版
好用的JavaScript開發工具

禪工作室 13.0.1
強大的PHP整合開發環境

Dreamweaver Mac版
視覺化網頁開發工具