如果
preg_match找不到匹配项,
$matches则为空数组。因此,您应该
preg_match在访问之前检查是否找到了匹配项
$matches[0],例如:
function get_match($regex,$content){ if (preg_match($regex,$content,$matches)) { return $matches[0]; } else { return null; }}
如果
preg_match找不到匹配项,
$matches则为空数组。因此,您应该
preg_match在访问之前检查是否找到了匹配项
$matches[0],例如:
function get_match($regex,$content){ if (preg_match($regex,$content,$matches)) { return $matches[0]; } else { return null; }}