易截截图软件、单文件、免安装、纯绿色、仅160KB

php之XML转数组函数

<?
/**
* xml2array() will convert the given XML text to an array in the XML structure.
* Link: http://www.bin-co.com/php/scripts/xml2array/
* Arguments : $contents - The XML text
* $get_attributes - 1 or 0. If this is 1 the function will get the attributes as well as the tag values - this results in a different array structure in the return value.
* $priority - Can be 'tag' or 'attribute'. This will change the way the resulting array sturcture. For 'tag', the tags are given more importance.
* Return: The parsed XML in an array form. Use print_r() to see the resulting array structure.
* Examples: $array = xml2array(file_get_contents('feed.xml'));
* $array = xml2array(file_get_contents('feed.xml', 1, 'attribute'));
*/
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(


相关文档:

浅谈用php对unicode转utf 8编码

(IT柏拉图 原创文章)如果只是unicode转utf-8编码的算法,网上到处都是了,不过很多人也是你抄我,我抄你,根本就不理解why和do,本文除了给出最简单的php对unicode转utf-8编码函数之外,也深入讨论了这两种编码的关系,理解好了会发现网上一些旧的东西,是严重多余兼过期的,因为从utf-8流行开始到现在,早已经由原来六字节 ......

PHP PDO 学习笔记

■PDO为何物?
POD(PHP Data Object)扩展在PHP5中加入,PHP6中将默认识用PDO连接数据库,所有非PDO扩展将会在PHP6被从扩展中移除。该扩展提供PHP内置类 PDO来对数据库进行访问,不同数据库使用相同的方法名,解决数据库连接不统一的问题。
我是配置在windows下做开发用的。
■PDO的目标
提供一种轻型、清晰、方便的 A ......

第一章 PHP概述 (重点回顾)

1.PHP是PHP: Hypertext Preprocessor的缩写,中文译为PHP:超文本预处理器.
2.PHP是一种简单的,面向对象的,解释型的,健壮的,安全的,性能非常高的,独立于架构的,可移植性的,动态的服务器端脚本语言.
3.PHP具有跨平台性,在大多数UNIX平台,Linux平台和微软Windows平台上都可以运行.
4.PHP支持JDBC,提供MYSQL,Oracle,Sybase和M ......

PHP环境安装和配置


集成环境:WAMP...(W-windows,里面有Apache服务器、Mysql、Php和Mysql可视化工具SQLite)
Ps:安装过程会有提示,是否自启动,默认开发目录、默认浏览器,安装完成后会在右下角有个小表盘,因为默认安装完成后是英文版的,在小表盘上点右键-->language-->选择中文就行)
开发工具:easyeclipse
php...还不错的一个开 ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号