|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[1998-08-07 12:10 UTC] rasmus
|
|||||||||||||||||||||||||||
Copyright © 2001-2026 The PHP GroupAll rights reserved. |
Last updated: Wed Jun 17 13:08:35 2026 UTC |
The following is the source: #!/usr/local/bin/php -q <? $fd = fopen("file.txt", "r"); while(!feof($fd)) { $line_data = fgets($fd, 100); $line = split("\)\" ", $line_data, 2); $final = ereg_replace("\r\n", "", $line[1]); $mypath = "/usr/temp/" . $final; echo("$mypath"); } fclose($fd); ?> And "file.txt" is just a few lines from an Apache extended log file. If you run this against file.txt that contains the following line: who.is.john.galt.com - - [05/Aug/1998:18:46:42 -0400] "GET / HTTP/1.1" 200 1906 "-" "Mozilla/4.0 (compatible; MSIE 4.01; Windows NT)" cp.clever.net It will output the following: /usr/temp/usr/temp/cp.clever.net I only want it to output: /usr/temp/cp.clever.net