原:$currentStr =<abbr class="timeago" title="2015-12-27 22:32:02 +0800">22:32</abbr>
目标: 2015-12-27 22:32:02
代码:
$before = "class=\"timeago\" title=\"";
$end = " \+0800\">";
$pattern = "/".$before."(.*)".$end."/U";//匹配指定字符开头,指定字符结尾。
preg_match_all($pattern, $currentStr, $matches_current);
$time = $matches_current[1][0];
before和end写上你的开头和结尾字符串,记得特殊字符要用\转义。
preg_match_all 运行一下,然后var_dump()结果,就能看懂这个命令的输出了