更多>
最新下载
24小时阅读排行榜
- 1 小黑盒加速器官方下载_小黑盒游戏加速器最新版
- 2 mc.js网页版在线玩 mc.js游戏世界入口
- 3 Edge浏览器收藏网页的快捷键
- 4 VSCode用户设置同步功能
- 5 联想ThinkPlus真无线和摩托罗拉VerveBuds哪款更耐用_联想与摩托罗拉蓝牙耳机综合对比
- 6 芒果发黑还能吃吗 芒果坏了如何辨别
- 7 如何为Laravel创建自定义命令_Artisan自定义命令行工具开发
- 8 vscode怎么用git比较分支差异_vscode比较两个git分支之间差异的方法
- 9 iPhone17Pro怎样查看存储空间_iPhone17Pro存储占用情况查看与清理方法
- 10 windows10如何设置文件夹背景颜色或图片_windows10文件夹背景自定义方法
- 11 Go语言:高效实现IP地址范围检查
- 12 edge浏览器启动时如何恢复上次的会话_Edge自动恢复标签页设置
- 13 php调用内存优化技巧_php调用垃圾回收机制优化
- 14 Go语言中获取Map元素数量的正确姿势
- 15 c++中静态多态和动态多态的实现_c++编译期与运行期多态机制对比
更多>
最新教程
-
- Node.js 教程
- 7475 2025-08-28
-
- CSS3 教程
- 1050544 2025-08-27
-
- Rust 教程
- 11854 2025-08-27
-
- Vue 教程
- 14087 2025-08-22
-
- PostgreSQL 教程
- 10843 2025-08-21
-
- Git 教程
- 5165 2025-08-21
下载首页 / 类库下载 / 其它类库
<?php
function xml2array($contents, $get_attributes = 1, $priority = 'tag') {
if (!$contents) return array();
if (!function_exists('xml_parser_create')) {
// print "'xml_parser_create()' function not found!";
return array();
}
// Get the XML parser of PHP - PHP must have this module for the parser to work
$parser = xml_parser_create('');
xml_parser_set_option($parser, XML_OPTION_TARGET_ENCODING, "UTF-8"); // http://minutillo.com/steve/weblog/2004/6/17/php-xml-and-character-encodings-a-tale-of-sadness-rage-and-data-loss
xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, 0);
xml_parser_set_option($parser, XML_OPTION_SKIP_WHITE, 1);
xml_parse_into_struct($parser, trim($contents), $xml_values);
xml_parser_free($parser);
if (!$xml_values) return; //Hmm...
// Initializations
$xml_array = array();
$parents = array();
$opened_tags = array();
$arr = array();
$current = &$xml_array; //Refference
// Go through the tags.
$repeated_tag_index = array(); //Multiple tags with same name will be turned into an array
foreach($xml_values as $data) {
unset($attributes, $value); //Remove existing values, or there will be trouble
// This command will extract these variables into the foreach scope
// tag(string), type(string), level(int), attributes(array).
extract($data); //We could use the array by itself, but this cooler.
$result = array();
$attributes_data = array();
if (isset($value)) {
if ($priority == 'tag') $result = $value;
else $result['value'] = $value; //Put the value in a assoc array if we are in the 'Attribute' mode
}这是一个可以在XML和数据格式中互相转换的类库,需要的朋友可以下载使用。
本站所有资源都是由网友投搞发布,或转载各大下载站,请自行检测软件的完整性!本站所有资源仅供学习与参考,请勿用于商业用途,否则产生的一切后果将由您自己承担!如有侵权请联系我们删除下架,联系方式:admin@php.cn

