易截截图软件、单文件、免安装、纯绿色、仅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面试题目(已注答案)


简述题(50分)()
1、用PHP打印出前一天的时间格式是2006-5-10 22:21:21(2分)
echo date('Y-m-d H:i:s', strtotime('-1 day'));
或者
$yesterday = time() - (24 * 60 * 60);
echo 'today:'.date('Y-m-d H:i:s')."\n";
echo 'yesterday:'. date('Y-m-d H:i:s', $yesterday)."\n";
2、echo(),pr ......

mysql+php select 下拉列表树的简单实现


数据库设计:
--
-- 数据库: `test`
--
-- --------------------------------------------------------
--
-- 表的结构 `menu`
--
CREATE TABLE IF NOT EXISTS `menu` (
`ID` int(10) unsigned NOT NULL auto_increment,
`PID` int(11) NOT NULL,
`TITLE` varchar(200) NOT NULL,
`REMARK` varchar(200) NOT ......

php 链接oracle php调用oracle存储过程


php调用oracle行存储过程############################################################
PHP程序访问数据库,完全可以使用存储过程,有人认为使用存储过程便于维护
不过仁者见仁,智者见智。
在这个问题上,偶认为使用存储过程意味着必须要DBA和开发人员更紧密配合,如果其中一方更变,则显然难以维护。
但是使用存储 ......

Php与Mysql

Php连接mysql的函数如下:
mysql_connect("主机名","用户名","密码");//打开一个连接
mysql_select_db("打开数据库",连接标识符);//打开一个数据库
$conn=@mysql_connect("localhost","root","") or die("链接错误");这里@可以隐藏错误提示,or die可以在错误的时候显示。
执行sql语句的函数:
mysql_query();
$sql="s ......

PHP data函数的常用参数

a - 小写的am或pm
A - 大写的AM或PM
d - 日,两位数字,不足两位则前导自动补零
D - 表示星期的英文的前三个英文字母
F - 月份的英文全名
h - 12小时制,两位数字,不足两位则前导自动补零
H - 24小时制,两位数字,不足两位则前导自动补零
g - 12小时制,不足两位的小时不补零
G - 24小时制,不足两位的小时不补零 ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号