How to detect and remove any url from string using php

Sometimes, We have to remove any url from a string to display, for example, you have got a content string from a pdf file, however, this string contains some urls, you have to remove them before displaying on you site.

Consider a string from a pdf file:

“M A N N I N G Mark Fisher Jonas Partner Marius Bogoevici Iwein Fuld FOREWORD BY Rod Johnson IN ACTION Spring Integration in Action Spring Integration in Action MARK FISHER JONAS PARTNER MARIUS BOGOEVICI”.

Here are three website urls:

You should detect and remove them from this string.

How to remove them?

Here we write a function example using php, you can follow it.

function removeURLS($str=""){














return $str;