note 109765 added to function.get-headers

From: Date: Fri, 17 Aug 2012 20:50:34 +0000
Subject: note 109765 added to function.get-headers
Groups: php.notes 
Request: Send a blank email to php-notes+get-190123@lists.php.net to get a copy of this message
To expand on gabe at vtunnel dot com 's curl based solution http://www.php.net/manual/en/function.get-headers.php#90434 You can use simple regex if you need the array keys named as if you were using get_headers() with the format flag ex) get_headers(1) function get_headers_curl($url) { $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_HEADER, true); curl_setopt($ch, CURLOPT_NOBODY, true); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_TIMEOUT, 15); $r = curl_exec($ch); $r = split("\n", $r); $keys = array(); if(!empty($r)) $keys[] = array_shift($r); foreach($r as $line){ preg_match('/.+:\s/',$line,$match); if($match) $keys[substr($match[0],0,-2)] = preg_replace('/.+:\s/','', $line); } return $keys; } ---- Server IP: 69.147.83.197 Probable Submitter: 69.65.5.30 ---- Manual Page -- http://www.php.net/manual/en/function.get-headers.php Edit -- https://master.php.net/note/edit/109765 Del: integrated -- https://master.php.net/note/delete/109765/integrated Del: useless -- https://master.php.net/note/delete/109765/useless Del: bad code -- https://master.php.net/note/delete/109765/bad+code Del: spam -- https://master.php.net/note/delete/109765/spam Del: non-english -- https://master.php.net/note/delete/109765/non-english Del: in docs -- https://master.php.net/note/delete/109765/in+docs Del: other reasons-- https://master.php.net/note/delete/109765 Reject -- https://master.php.net/note/reject/109765 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#190123) next »