/*
@desc:xml轉(zhuǎn)數(shù)組
@param data xml字符串
@return arr 解析出的數(shù)組
*/
function xmltoarray($data){
$obj = simplexml_load_string($data, 'SimpleXMLElement', LIBXML_NOCDATA);
$json = json_encode($obj);
$arr = json_decode($json, true);
return $arr;
}
Forty What?
Joe
Jane
I know that's the answer -- but what's the question?
XML;
$arr = xmltoarray($string);
var_dump($arr);
b. 輸出:
創(chuàng)新互聯(lián)成立十余年來(lái),這條路我們正越走越好,積累了技術(shù)與客戶(hù)資源,形成了良好的口碑。為客戶(hù)提供網(wǎng)站制作、網(wǎng)站設(shè)計(jì)、網(wǎng)站策劃、網(wǎng)頁(yè)設(shè)計(jì)、域名注冊(cè)、網(wǎng)絡(luò)營(yíng)銷(xiāo)、VI設(shè)計(jì)、網(wǎng)站改版、漏洞修補(bǔ)等服務(wù)。網(wǎng)站是否美觀、功能強(qiáng)大、用戶(hù)體驗(yàn)好、性?xún)r(jià)比高、打開(kāi)快等等,這些對(duì)于網(wǎng)站建設(shè)都非常重要,創(chuàng)新互聯(lián)通過(guò)對(duì)建站技術(shù)性的掌握、對(duì)創(chuàng)意設(shè)計(jì)的研究為客戶(hù)提供一站式互聯(lián)網(wǎng)解決方案,攜手廣大客戶(hù),共同發(fā)展進(jìn)步。
array(4) {
["title"]=>
string(11) "Forty What?"
["from"]=>
string(3) "Joe"
["to"]=>
string(4) "Jane"
["body"]=>
string(57) "
I know that's the answer -- but what's the question?
"
}