php判断unix时间戳大小疑点

WBOY
Release: 2016-06-13 13:51:43
Original
964 people have browsed it

php判断unix时间戳大小问题
一段内容加了function要做的判断就是判断这段内容最后的数字是否大于系统当前的unix时间戳

例如

标题(标题内容不是固定的) 1324570103

这段内容就是提取里的unix时间戳和当前系统的unix时间戳比较,判断大小,比时间戳大的则返回,否则不显示

我知道是return "$str" 和return" "

但是中间的判断还请高手帮忙分析下


------解决方案--------------------

PHP code
function getContent($source){
   if(empty($source)) return "";
   $str = "这是我要返回的值了";
   preg_match('/<span>(\d+)/isU',$source,$matches);
   if($matches[1]>time()){
      return $str;
   }else{
      return "";
   }
}

//使用方法
date_default_timezone_set("Asia/shanghai");
$content ='<span>1324570103</span>';
$res = getContent($content); <div class="clear">
                 
              
              
        
            </div></span>
Copy after login

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!