📜  php 检查未定义的偏移量 - PHP 代码示例

📅  最后修改于: 2022-03-11 14:53:49.830000             🧑  作者: Mango

代码示例2
If preg_match did not find a match, $matches is an empty array. So you should check if preg_match found an match before accessing $matches[0], for example:

function get_match($regex,$content)
{
    if (preg_match($regex,$content,$matches)) {
        return $matches[0];
    } else {
        return null;
    }
}