Jump to content

Find url but not if it's in a sentance


ebolt007

Recommended Posts

I'm trying to write a piece that checks to see if something someone posts is a url or if it's just a url in a sentence.

Basically, I want it so if someone puts in

 

www.phpfreaks.com (then it does something)

 

but if they put

 

I am on www.phpfreaks.com where are you? (Then it does something else)

 

Like the first one will get the dom of the page and post that, and the second one would just post the sentence with the url in it as a link.

 

So I am getting my post

$Post

checking if there is a www or .com or .net or .gov in it

                                        $find2 = 'www.';

                                    $find3 = '.com';

                                    $find4 = '.net';

                                    $find5 = '.gov';

if((strstr($Post, $find2) ==true)||(strstr($Post, $find3) ==true)||(strstr($Post, $find4) ==true)||(strstr($Post, $find5) ==true)){

 

then do I explode the whole thing, or what would I do in here with the $Post? some people might put in just phpfreaks.com others might put in http://www.phpfreaks.com and others might put in http://www.phpfreaks.com/forums/index.php?action=post;board=1.0 so I need to find the www. and or .com and find the first space before that, and after that and cut out the middle section, but I'm at a loss.

 

}

 

 

Link to comment
https://forums.phpfreaks.com/topic/260035-find-url-but-not-if-its-in-a-sentance/
Share on other sites

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.