mars_rahul Posted December 16, 2007 Share Posted December 16, 2007 here is the string with link tags in. $string = "this is the string. www.clickhere.com". i wish to display only "www.clickhere.com" (it is a link) from the above string. what should i do for this. please explain me in detail if anybody can solve this problem. Quote Link to comment Share on other sites More sharing options...
corbin Posted December 16, 2007 Share Posted December 16, 2007 $str = 'Hi my name is corbin <a href="http://google.com/">This is google!</a>'; if(preg_match('/<a(.*?)href="(.*?)">(.*?)<\/a>/', $str, $match)) { print_r($match); } Outputs: Array ( [0] => <a href="http://google.com/">This is google!</a> [1] => [2] => http://google.com/ [3] => This is google! ) Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.