一段内容加了function要做的判断就是判断这段内容最后的数字是否大于系统当前的unix时间戳例如标题(标题内容不是固定的)  <span>1324570103</span>这段内容就是提取<span>里的unix时间戳和当前系统的unix时间戳比较,判断大小,比时间戳大的则返回,否则不显示我知道是return "$str" 和return" "但是中间的判断还请高手帮忙分析下

解决方案 »

  1.   

    function getContent($source){
       if(empty($source)) return "";
       $str = "这是我要返回的值了";
       preg_match('/<span>(\d+)<\/span>/isU',$source,$matches);
       if($matches[1]>time()){
          return $str;
       }else{
          return "";
       }
    }//使用方法
    date_default_timezone_set("Asia/shanghai");
    $content ='<span>1324570103</span>';
    $res = getContent($content);