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>
PHP怎么学习?PHP怎么入门?PHP在哪学?PHP怎么学才快?不用担心,这里为大家提供了PHP速学教程(入门到精通),有需要的小伙伴保存下载就能学习啦!
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号