<div class="codetitle"><a style="CURSOR: pointer" data="6707" class="copybut" id="copybut6707" onclick="doCopy('code6707')"> 代码如下:<div class="codebody" id="code6707"> // 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; } // Xml 转 数组,不包括根键 function xmltoarray( $xml ) { $arr = xml_to_array($xml); $key = array_keys($arr); return $arr[$key[0]]; }
(编辑:李大同)
【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!
|