php xml字符串转化为 array数组的代码

    /**
     * XML转数组
     * @param string $xmlstring XML字符串
     *
     * @return array XML数组
     */
    public static function toArray($xmlstring)
    {
        $object = simplexml_load_string($xmlstring, 'SimpleXMLElement', LIBXML_NOCDATA | LIBXML_NOBLANKS);
        
        return @json_decode(@json_encode($object),1);
    }

你可能感兴趣的:(xml,PHP)