note 53493 added to function.get-headers

From: Date: Fri, 03 Jun 2005 09:44:26 +0000
Subject: note 53493 added to function.get-headers
Groups: php.notes 
Request: Send a blank email to php-notes+get-89850@lists.php.net to get a copy of this message
aeontech, I'd edit your function a little... How about replacing this: <? $key = array_shift(explode(':',$header)); // the first element is the http header type, such as HTTP 200 OK, // it doesn't have a separate name, so we have to check for it. if($key == $header) { $headers[] = $header; } else { $headers[$key]=substr($header,strlen($key)+2); } ?> with this: <? $h2 = explode(':',$header); // the first element is the http header type, such as HTTP/1.1 200 OK, // it doesn't have a separate name, so we have to check for it. if($h2[0] == $header) { $headers[] = $header; } else { $headers[ $h2[0] ] = trim($h2[1]); } ?> I think it looks a bit nicer :) ---- Manual Page -- http://www.php.net/manual/en/function.get-headers.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+53493 Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+53493&report=yes&reason=added+to+the+manual Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+53493&report=yes&reason=bad+code Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+53493&report=yes&reason=spam Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+53493&report=yes&reason=useless Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+53493&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+53493&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#89850) next »