1// $key = 10, if $array does not have $array[10] set, it will return false
2// If $array[10] has any value, it will return true
3if(array_key_exists($key, $array)){}
1If 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:
2
3function get_match($regex,$content)
4{
5 if (preg_match($regex,$content,$matches)) {
6 return $matches[0];
7 } else {
8 return null;
9 }
10}