Jump to content

Removing http:// links from a string


etrader

Recommended Posts

this works with a simple test, but might need tweaked

 

$content = "AS DGASDGAsa 3434 434SDGASDGADGhttp://www.cnn.com/something/somethingelse.html?whatever=4535&test=sagasdg MORE CONTENT heraes tq435345345q";

$pattern = '~http://[^\s]*~i';

$content = preg_replace($pattern, '', $content);

echo "content: $content ";

 

output:

 

content: AS DGASDGAsa 3434 434SDGASDGADG MORE CONTENT heraes tq435345345q

You could remove the link based on the location of the http:// (or https://) and the location of the first space after the position of the http:// part. Note that this will fail if there is a space in the link.

http://www.example.com/my page.html

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.