Jump to content

[SOLVED] Strign Seperator on " | "


d22552000

Recommended Posts

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.

Link to comment
https://forums.phpfreaks.com/topic/68512-solved-strign-seperator-on/
Share on other sites

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";
}

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.