Hi, Thursday, April 29, 2004, 1:31:07 AM, you wrote: LG> Hello everyone, LG> I've been putzing with this for about a week on and off now. LG> I've googled like crazy and tried to figure out the regexps, but I LG> can't just get it. LG> What I'm doing is taking some code I found to show me the HTTP LG> headers from a remote server and making it a bit more dynamic with a LG> runtime input, and to format the output nicely. I can retrieve the LG> headers just fine, but I can't get the output broken out into pieces LG> from the returned single line. LG> i.e. LG> HTTP/1.1 200 OK Date: Tue, 20 Apr 2004 17:28:23 GMT Server: LG> Microsoft-IIS/5.0 Last-modified: Thu, 01 Jan 2004 19:56:39 GMT LG> Connection: close Content-type: text/html LG> I want to format it as such by breaking each line into its own LG> array element: LG> HTTP/1.1 200 OK LG> Date: Tue, 20 Apr 2004 17:28:23 GMT LG> Server: Microsoft-IIS/5.0 LG> Last-modified: Thu, 01 Jan 2004 19:56:39 GMT LG> Connection: close LG> Content-type: text/html LG> Any help would really be appreciated. LG> BTW, this is PHP 4.3.4 on Win2K Pro running under Sambar. LG> Here's the code: LG> ,------ [ ] LG> | <HTML> LG> | <HEAD> LG> | </HEAD> LG> | <BODY> LG> | LG> | This will return the HTTP headers for a site to determine LG> SERVER type, cookies, sessions etc. LG> | <br><br> LG> | LG> | <form> LG> | <input type="text" name="URL" value="URL"> LG> | <input type="SUBMIT" name="SUBMIT"> LG> | </form> LG> | LG> | <? LG> | if (isset($_GET['URL'])) LG> | { LG> | $fp = fsockopen ($_GET['URL'], 80, $errno, $errstr, 30); LG> | if (!$fp) LG> | { LG> | echo "$errstr ($errno)<br>\n"; LG> | } LG> | else LG> | { LG> | fputs($fp, "GET / HTTP/1.0\r\nHost: " . $_GET['URL'] . "\r\n\r\n"); LG> | LG> | //This part allows me to see the headers but on a single line LG> | //while (!feof($fp)) LG> | //{ LG> | // echo fgets($fp,256); LG> | // } LG> | //fclose ($fp); LG> | //} LG> | LG> | //This is the part I can't figure out LG> | preg_match_all ("Date:\s*.*?\s\S*:\s*|\z", fgets($fp,256), $server); LG> | echo $server; LG> | fclose($fp); LG> | } LG> | LG> | LG> | //Some other stuff I tried. LG> | //preg_match_all ("/HTTP.*?K/", fgets($fp,256), $server); LG> | //echo $server[1]; LG> | //fclose($fp); LG> | //} LG> | //echo "Method: " . substr("$pagedata", 0, 15) . "<br />"; LG> | //echo substr("$pagedata", 16, 36) . "<br />"; LG> | //echo substr("$pagedata", 52, 67) . "<br />"; LG> | LG> | } LG> | | ?>> LG> | </BODY> LG> | </HTML> LG> `---------- LG> Tagline of the day: LG> The problem with paradigms is that shift happens. LG> -- LG> Leif (TB lists moderator and fellow end user). LG> Using The Bat! 2.10 RC/1 under Windows 2000 5.0 LG> Build 2195 Service Pack 4 on a Pentium 4 2GHz with 512MB The header has line breaks you will need to nl2br() to view them in html -- regards, Tom -- PHP Windows Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php