Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PHP

php undefined offset

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;
    }
}
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #php #undefined #offset
ADD COMMENT
Topic
Name
6+9 =