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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.