1、去掉mysql数据库中某字段的换行符和回车符:replace函数UPDATE student SET name = REPLACE(REPLACE(title,CHAR(10),''),CHAR(13),'') WHERE ID = xxxxxx; 注解:CHAR(10),'':将换行符CHAR(10)替换成空串,可理解为删除换行符CHAR(13),'':将回车符CHAR(13)替换成空串,可理解为删除回车符2、往mysql某个字段中插入换行符和回车符:concat函数concat函数可以连接一个或者多个字符串,若其中一个为null,则返回nullUPDATE student SET...
用法:downpic($url,'/www/wwwroot/www.xxx123.com/'); //下载远程图片 function downpic($url,$path){ $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); $header = array(); $header[] = 'Host: t.xx.com'; $header[] = 'Accept-Enco...
/**获取文章内容html中第一张图片地址 */function get_html_first_imgurl($html){//匹配图片的srcpreg_match_all('#<img.*?src="([^"]*)"[^>]*>#i', $html, $match); foreach($match[1] as $imgurl){ $imgurl = $imgurl; if(is_int(strpos($imgurl, 'http'))){ $arcurl = $imgurl; } else {...
function getimglist($xstr, $oriweb){ //匹配图片的src preg_match_all('#<img.*?src="([^"]*)"[^>]*>#i', $xstr, $match); foreach($match[1] as $imgurl){ $imgurl = $imgurl; if(is_int(strpos($imgurl, 'http'))){ $arcurl = $imgurl; } e...
//下载远程图片function down_pic($url,$path){ $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); $header = array(); $header[] = 'Host: t.xx.com'; $header[] = 'Accept-Encoding: gzip, deflate, sdch'; $header[] = 'Accept-Language: zh-CN,zh;q=0.8'; $header[] = 'Cookie: _hc.v=...
/** * 根绝文件路径创建对应的目录 * * @param string $path a/b/c/d/ * */ function makeDirByPath($path){ if(!file_exists($path)){ makeDirByPath(dirname($path)); mkdir($path, 0777); } }
https://www.xxx.com/upload/attach/202010/1_GWX3MVCB5SARKGF.jpg upload/attach/202010/ echo geturlPath($url,"https://www.xxx.com/").'<br/>';; function geturlPath($url,$wwwurl){ $makeDir= str_replace($wwwurl,"",$url); $netfilename=basename($makeDir); //echo $netfilename....
delete from clicklog where time <= date_sub(curdate(),INTERVAL 15 day) limit 5000; /*删除15日前的数据*/ delete From clicklog where DATE(time) <= DATE(DATE_SUB(NOW(),INTERVAL 15 day)) limit 5000; /*删除15日前的数据*/
<?php function curlget($url,$method='get',$data=null){ $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 1000); curl_setopt($ch, CURLOPT_TIMEOUT, 500); curl_setop...
PHP实现图片指定区域打印文字和图片 在一些通过模板制作效果图的需求中需要用到图片上加文字或者加图片。 下面这个类可以实现在某个区域内(通过left、top,width、height圈定区域)内居中打印文字和图片,文字可以自动换行,水平和垂直居中。 <?php //拼图 class DrawText{ private $sourceImg; //原图 public $sourceImgSize = [0,0]; //原图尺寸 private $location_x = 0; private $loca...