下面有一个HTML字符串。
<?php $str="<td class="team_info" align="center" height="26"><strong>Match Time:<script language="Javascript" type="text/javascript">formatDate('2017,6,11,23,30,00',1)</script>7/12/2017 06:30 Wednesday </strong></td>"
?>
我想获得字符串'2017,6,11,23,30,00'并将每个数字放入数组中。请帮忙 。谢谢朋友们。
答案 0 :(得分:0)
使用以下代码:
$str="<td class=\"team_info\" align=\"center\" height=\"26\"><strong>Match Time:<script language=\"Javascript\" type=\"text/javascript\">formatDate('2017,6,11,23,30,00',1)</script>7/12/2017 06:30 Wednesday </strong></td>";
preg_match("/'([0-9,\s]+)'/", $str, $matches);
if(count($matches) > 1) {
print_r(explode(',', $matches[1]));
}