您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息

php下将XML转换为数组的方法

2024/2/27 22:23:57发布11次查看
php xml to array,将xml转换为数组,需要的朋友可以参考下。
// xml 转 数组, 包括根键function xml_to_array( $xml ){$reg = /]*>([\\x00-\\xff]*)/;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;}// xml 转 数组, 不包括根键function xmltoarray( $xml ){$arr = xml_to_array($xml);$key = array_keys($arr);return $arr[$key[0]];}
该用户其它信息

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录 Product