php常用工具函数

1:翻转中英文字符串。

/**
 * 翻译中英文字符串
 */
function m_strrev($string){
   $num = mb_strlen($string,'utf-8');
   $new_string = "";
   for($i=$num-1;$i>=0;$i--){ 
      $char = mb_substr($string,$i,1,'utf-8');
      $new_string .= $char;
   }
   return $new_string;
}

2:获取本月,本周,今日的开始时间戳。

date_default_timezone_set("Asia/Chongqing");
//获取本月
$month = strtotime(date('Y-m'));
//获取今日
$today = strtotime(date('Y-m-d'));
//获取本周,借助php自带的DateTime类
$Date = new DateTime();
$week= strtotime($Date->modify('this week')->format('Y-m-d'));

猜你喜欢

转载自blog.csdn.net/eclothy/article/details/45888577
今日推荐