Jump to content

Remove http://


SkyRanger

Recommended Posts

Not sure if this is possible.  What I am trying to do is remove a section of text a user posts.

 

ie:  go to this url:  http://url.com  or http://this.domain.org

 

I already have it to strip they <a href="whatever

 

but not sure if I can do the other.

 

Any help would be appreciated.

 

Thanks

Link to comment
https://forums.phpfreaks.com/topic/233487-remove-http/
Share on other sites

Ok how would I do that if it is in the middle of a test ie:

 

 

Hello visit this site it is cool http://www.thissite.com

 

$comtext = "Hello visit this site it is cool http://www.thissite.com"

 

This is the code i have now:

$comname = $rowco['mcname'];
$comtext = $rowco['mctext'];

echo "<b>";
echo strip_tags($comname);
echo "</b><br>";
echo nl2br(strip_tags($comtext));
echo "<hr>";

Link to comment
https://forums.phpfreaks.com/topic/233487-remove-http/#findComment-1200595
Share on other sites

Guess I never got it working...well sort of.  using str_replace I can get the http:// and www. to  remove using an array.  But is there a way using string replace to remove the who URL that somebody posts.  It might be in the str_replace php page but I seem to be overlooking something.

 

$urlgarbage = array("http://", "www.");
$comtext = str_replace($urlgarbage, 'BADCODE', $comtexta); 

echo $comtext;

 

So what I am saying is I would like to do something like:

 

Change:  Check out http://www.thissite.tld now.

To:  Check out BADCODE now.

 

Is this possible using str_replace?

 

 

Link to comment
https://forums.phpfreaks.com/topic/233487-remove-http/#findComment-1200628
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.