Answers for "check undefined offset array php"

PHP
4

limit offset array php

array_slice($array, 0, 50); // same as offset 0 limit 50 in sql
Posted by: Guest on September-02-2020
0

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;
    }
}
Posted by: Guest on June-06-2020

Browse Popular Code Answers by Language