PHP xml转数组

 if (!function_exists('xml_to_array')) {
            /**
             * 将XML转为array
             * Author:刘星麟
             * @param $xml
             * @return mixed
             */
            function xml_to_array($xml){
                libxml_disable_entity_loader(true); //禁止引用外部xml实体
                $array= json_decode(json_encode(simplexml_load_string($xml, 'SimpleXMLElement', LIBXML_NOCDATA)), true);
                return $array;
            }
        }

猜你喜欢

转载自blog.csdn.net/liuxl57805678/article/details/103298393