0

I'm getting a PHP

"Notice: Undefined offset: 1" notice for the following on line 6,

does anyone know why this is occurring and how I might fix it?

$data=explode("\n",$header);
$myarray['status']=$data[0];
array_shift($data);
foreach($data as $part){
    $middle=explode(": ",$part);
    $myarray[trim($middle[0])] = trim($middle[1]);
}
Alive to die - Anant
  • 70,531
  • 10
  • 51
  • 98
user1419810
  • 836
  • 1
  • 16
  • 29
  • this is because $middle array size is no longer than 1.check the header returned first to see if is there any response at all or all parts match "something : something else" pattern (like the body part of a get request response does not match this pattern) – Aref Anafgeh Jun 30 '16 at 04:59
  • Notice message showing because `$message[1]` is undefined. If you dont want to see notice alerts, read more about `error_reporting` here: http://php.net/manual/function.error-reporting.php – Sergey Khalitov Jun 30 '16 at 05:02
  • if you debug your code (simply by printing each variable) you will itself come to know where the problem exist – Alive to die - Anant Jun 30 '16 at 05:05

0 Answers0