I want to be able to find and replace all clickable links in a piece of text with some custom information. Please consider the following example:
This is a sample text. Visit: http://www.microsoft.com/help.asp Sample text. Please visit http://www.mydomain.com/sometime.jpg. This is some random text. And this is some random sample text. Visit http://www.mydomain.com/help.php for more help. Visit http://www.mydomain.com/contact.php if you wish to contact us.
In the above text, I want to be able to replace all clickable ".php" links to something like below:
This is a sample text. Visit: http://www.microsoft.com/help.asp Sample text. Please visit http://www.mydomain.com/sometime.jpg. This is some random text. And this is some random sample text. Visit http://www.mydomain.com/mypage.php?url=help.php for more help. Visit http://www.mydomain.com/mypage.php?url=contact.php if you wish to contact us.
I tried using preg_replace and ereg_replace but it did not work for me.
All help is appreciated. Thank you.