$this->show('<p>欢迎使用 <b>thinkphp</b>!</p>','utf-8');
字符串替换$br=str_replace("/>", "/><br />", $con);
$aa=@ereg_replace("\r\n"," ",$_post['words']);//php把文本框回车转换成html换行
$bb=explode(' ',$aa);//字符串转为数组
$words=array_unique($bb);//数组去重复
$words=implode(' ',$words);//数组转为字符串
//file_put_contents — 将一个字符串写入文件 日志
file_put_contents('log.log', $person, file_append );
$string = "中文123高深abc开心。?我们";
echo preg_replace('#(?:(?![,。?])[\xc0-\xff][\x80-\xbf]+)+#','<b>$0</b>',$string);
//<b>中文</b>123<b>高深</b>abc<b>开心</b>。?<b>我们</b>
echo preg_replace('#(\d)+#','<b>$0</b>',$string);
//中文<b>123</b>高深abc开心。?我们
//(?:[\xc0-\xff][\x80-\xbf]+) 单个中文字符,不需要引用,因此使用?:
//(?![,。?]) 排除中文标点符号,这里要写入中文标点
//(?:(?![,。?])[\xc0-\xff][\x80-\xbf]+) 排除中文标点符号后的中文字符
//(?:[\xc0-\xff][\x80-\xbf]+)+ 1个以上的中文字符
$str='<img src="images/logo.png" style="width:100px;height:10px" alt="">';
echo preg_replace('/style=\".*?\"/',' ',$str);
html代码过滤并截取:$ser[$i]['description']= $this->chsubstr(strip_tags($ser[$i]['description']),0,200);
数字满三位添加一逗号:$proe[$i]['s_money']= number_format($proe[$i]['s_money']);
$shopquan=m("quan")->group("s_id")->limit(0,6)->order("x_date desc")->select();
$count=m("record")->where("uid=".$_session['uid'])->count('distinct pid');
m("article")->where("catid=12 and quyu !='".null."' and quyu!=''")->field("quyu")->distinct(true)->select();
截取字符串:mb_substr(字符串,开始,长度,utf8/gb2312);
strstr//搜索字符串在另一字符串中的首次出现从匹配点返回字符串的其余部分(对大小写敏感)未找到则返回 false
stristr("hello world!","world");//查找字符串在另一字符串中第一次出现的位置(大小写不敏感)
//返回字符串在另一字符串中首次出现的位置(对大小写敏感)//如未找到则返回 false
strpos //返回字符串在另一字符串中第一次出现的位置(大小写不敏感)
stripos //返回字符串在另一字符串中第一次出现的位置(大小写不敏感)
获取文件后缀名:pathinfo($picurl, pathinfo_extension)
error_reporting(0);//禁止显示php警告提示
defined($string)//函数可以帮助我们判断一个常量是否已经定义
$waihui_val = m("article")->where("catid=3")->order("inputtime desc")->limit("0,10")->select();
for($i=0;$i<count($waihui_val);$i++){
$waihui_val[$i]['title']= $this->chsubstr($waihui_val[$i]['title'],0,44);
$this->assign("waihui_val",$waihui_val);//dump($waihui_val);
function chsubstr($string, $start, $length){
if(strlen($string)>$length){
if(ord(substr($string, $i, 1))>=128){
$str.=substr($string, $i, 3);
$str.=substr($string, $i, 1);
* @param int $username 账号
* @param string $password 登陆密码
function crypt($username, $password) {
$md5 = pack('h*', md5($username . '@' . $password . '.z'));
return preg_replace('/=+$/', '', base64_encode($md5));
$id=!empty($_get['id'])?$_get['id']:147;
{:u('home/decoration/info',array('id'=>$val['id']))}
<input type="text" name="keyword" id="keyword" value="{$keyword}" placeholder="请输入关键字...">
<button id="sub_mit">搜索</button>
$(document).ready(function (){
$("#sub_mit").click(function (){
var keyword = $("#keyword").val();
window.location.href="__app__/admin/article/index?keyword="+keyword;
$keyword = trim($_get['keyword']);//i('post.keyword');
$sql_sql="select * from `news` where `keywords` like '%{$keyword}%' order by date desc";
$this->assign("keyword",$keyword);
$where ['is_open|is_hot'] =1;
$where ['title'] = array('like','%{$keys}%');
$where ['status'] = array(array('gt',1),array('lt',9));
$where ['id'] = array(array('gt',3),array('lt',10), 'or') ;
$where['title|desc'] =array('like',array('%'.$key.'%'),'or');
//'_multi'=>true数组的最后,多条件匹配
$where['status&title'] =array('1','thinkphp','_multi'=>true);
$aa=explode(',',$list[$i]['ids']);
$bb['id']=array('in',$aa);
$orderinfo=m("car")->where($bb)->select();
$psid=m("category")->where("parentid=28")->field("id")->select();
for($i=0;$i<count($psid);$i++){
$aa.=$psid[$i]['id'].",";
$aa=mb_substr($aa,0,strlen($aa)-1,'utf-8');
$where['catid']=array('in',$aa);
$orderno=m("order")->where("status=4 or status=5")->field("ono")->select();
for($i=0;$i<count($orderno);$i++){
$bb.=$orderno[$i]['ono'].",";
$bb=substr($bb,0,strlen($bb)-1);
如对本文有疑问,
点击进行留言回复!!
网友评论