PHP用正則表達式.XML轉數組. 原
function xml_to_array($xml){
$reg = "/<(\w+)[^>]*>([\\x00-\\xFF]*)<\\/\\1>/";
if(preg_match_all($reg, $xml, $matches)){
$count = count($matches[0]);
for($i = 0; $i < $count; $i++){
$subxml= $matches[2][$i];
$key = $matches[1][$i];
if(preg_match( $reg, $subxml )){
$arr[$key] = xml_to_array( $subxml );
}else{
$arr[$key] = $subxml;
}
}
}
return $arr;
}
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章
PHP 代碼行數統計
avenjan
2020-07-08 12:38:08
慎用PHP $_REQUEST數組
二两天涯
2020-07-08 12:16:43
php函數名前面加@是何意
二两天涯
2020-07-08 12:16:42
php,checkbox多選框上傳失敗
阿冰介
2020-07-08 11:48:15
php中的&&運算符
yangmingysc
2020-07-08 11:45:39
php+mysql存儲html文件
$fileContent = trim($fileContent); $fileContent=$queueList->characet($fileContent);
moliyiran
2020-07-08 11:15:53
php+go實現grpc
moliyiran
2020-07-08 11:15:42
Linux中PHP鏈接擴展.so動態庫
寒.
2020-07-08 11:14:55
PHP之TRUE與FALSE總結
taotaoyouarebaby
2020-07-08 11:05:39
PHP配置使PHP在頁面中支持輸出內容
念旧丶
2020-07-08 11:00:42
php操作xml最快的速度學習
jacklin_001
2020-07-08 10:52:26
wordpress數據字典
incloud_anke
2020-07-08 10:22:11
linux下面安裝php xdebug擴展
incloud_anke
2020-07-08 10:22:10