php
文章平均质量分 71
mr-song
it宅男
展开
-
php 过滤换行及空格
function delSE($str) { $str = preg_replace("/\s/","",$str); $str = str_replace("" , "",$str); $str = str_replace("", "",$str); $str = str_replace("", "",$str); return $str;}原创 2013-05-08 20:49:03 · 975 阅读 · 0 评论 -
php date function
private function whereDate($s,$e,$col) { $where = 'AND '; if(!empty($s) and !empty($e)) { $where .= "`$col` >= '{$s}' AND `$col` <= '{$e}' "; } elseif (!empty($s) AND empty原创 2013-05-09 11:07:37 · 491 阅读 · 0 评论 -
xml to array 方法
function xml2array($contents, $get_attributes=1, $priority = 'tag') { if(!$contents) return array(); if(!function_exists('xml_parser_create')) { //print "'xml_parser_create()' function not fo转载 2013-06-29 11:46:55 · 684 阅读 · 1 评论 -
php email验证
function checkEmail($inAddress){ return strlen($inAddress) > 6 && preg_match("/^[\w\-\.]+@[\w\-\.]+(\.\w+)+$/", $inAddress); }原创 2013-06-20 15:59:07 · 474 阅读 · 0 评论 -
curl, fsockopen ,file_get_contents
[php]php读取网络文件 curl, fsockopen ,file_get_contents 几个方法的效率对比curl效率及稳定原来可以远远超越file_get_contents最近需要获取别人网站上的音乐数据。用了file_get_contents函数,但是总是会遇到获取失败的问题,尽管按照手册中的 例子设置了超时,可多数时候不会奏效:$config['context转载 2013-05-09 11:10:09 · 663 阅读 · 0 评论 -
读XML
key:simplexml_load_file(); file_get_contents();张映男28 aaa bbbtank男28 ccc ddd<?php//$file = file_get_contents('http://bank.runsky.com.26.con/xml.xml');转载 2013-05-09 11:08:56 · 490 阅读 · 0 评论 -
php 按行读取文件
$filter = array(); /* 过滤关键字读取开始 */ $file = "key.ini"; if (file_exists($file)){ $file_handle = fopen($file, "r"); while (!feof($file_handle)) { $line = fgets($f原创 2013-05-08 20:52:12 · 8556 阅读 · 0 评论 -
文件解压缩 【php】
function unzip_file() {$file = "g:\\zip\\zip.zip";$zip = new ZipArchive() ;if ($zip->open($file) !== TRUE) {die ('Could not open archive');}$zip->extractTo("./zip/");$zip->close();}原创 2013-05-08 21:12:00 · 561 阅读 · 0 评论 -
PHP操作文件类(文件和文件夹创建,复制,移动和删除)
<?/*** 操纵文件类** 例子:* FileUtil::createDir('a/1/2/3'); 测试建立文件夹 建一个a/1/2/3文件夹* FileUtil::createFile('b/1/2/3'); 测试建立文件 在b/1/2/文件夹下面建一个3文件* FileUtil::cre转载 2013-05-08 21:17:54 · 450 阅读 · 0 评论 -
CURL 入门
http://www.chinaz.com/program/2010/0119/104346.shtmlhttp://www.php.net/manual/zh/function.curl-setopt.php以下为引用的内容:// 1. 初始化$ch = curl_init();// 2. 设置选项,包括URLcurl_setopt($ch, CURLOP原创 2013-05-08 21:14:02 · 501 阅读 · 0 评论 -
解决fgetcsv打开csv文件中文无法显示的问题。
上PHP官网翻了一下,原来加上setlocale即可解决。原本用PHP4没出现这问题,大概是PHP5才会这样吧...注释:setlocale() 函数仅针对当前脚本改变地区信息。提示:可以通过 setlocale(LC_ALL,NULL) 把地区信息设置为系统默认。// utf-8setlocale(LC_ALL, 'en_US.UTF-8');转载 2015-01-05 15:26:12 · 1135 阅读 · 0 评论