d22552000 Posted September 8, 2007 Share Posted September 8, 2007 Is it possible to take input and seperate it on every certain character or regular expression? then split whats before to one string and whats after to another string? I am making a webserver and I need to seperate the first line of a browser request: "GET / HTTP/1.1" is an example call for root on the webserver "GET /file/index.html HTTP/1.1" is a call for index in file directory. I have seen people do it to seperate a string url: $url = "http://domain.com/file" turns into $url1 = "http://" $url2 = "domain.com" $url3 = "/file" but I wonder how they did it... can you please help me? I posted the topic earlier (12h ago) but it got buried. Quote Link to comment Share on other sites More sharing options...
d22552000 Posted September 8, 2007 Author Share Posted September 8, 2007 would this work!!!?? $request = split("[\n\r\t ]+", $s); if ($request[2]=="/") { echo "You requested HOME"; } elseif $request[2]=="/*") { echo "You requested a file or directory: ".$request[2]; } else { echo "Your request was invalid"; } Quote Link to comment Share on other sites More sharing options...
AndyB Posted September 8, 2007 Share Posted September 8, 2007 I posted the topic earlier (12h ago) but it got buried. Then 'bump' it instead of opening another thread on the same topic. http://ca.php.net/manual/en/function.parse-url.php is probably what you're looking for Quote Link to comment Share on other sites More sharing options...
d22552000 Posted September 8, 2007 Author Share Posted September 8, 2007 pelase check fopen error for my recent problem. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.