0

I am getting this PHP error:

Undefined offset: 1

Code is:

public function setHttpResponseCodeFromHeader($rawResponseHeader)
{
    preg_match('|HTTP/\d\.\d\s+(\d+)\s+.*|', $rawResponseHeader, $match);
    $this->httpResponseCode = (int)$match[1];
}

How to solve this error?

Mark
  • 25
  • 5

1 Answers1

1

Is the array $match initialized before you accessing it? Try that before you accessing $match

$match = [];
//or
$match = array();
Strider
  • 134
  • 7