PHP学习小记

//获取字符串长度 
strlen($abc);

//替换字符串中的字符 
strtr($abc,'-','-');

//拆分字符串 
explode("-",$abc);

//编码字符串 
urlencode($abc);

//格式化日期 
date('Y-m-d',strtotime($abc));

//判断当前日期和指定日期相差几天 
(strtotime($today)-strtotime($gd))/3600/24;

//UTF-8编码下全角符号替换成半角

$tags
= "0123ABCDFWS\",.?<>{}[]*&^%#@!~()+-|:;"; print_r($tags);
$tags = iconv('utf-8', 'gbk', $tags); $tags = preg_replace('/\xa3([\xa1-\xfe])/e', 'chr(ord(\1)-0x80)', $tags);
$tags = iconv( 'gbk', 'utf-8', $tags);
print_r($tags);


 

原文地址:https://www.cnblogs.com/enone/p/2672425.html