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. Link to comment https://forums.phpfreaks.com/topic/81934-solved-replace-whole-string/ 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! ) Link to comment https://forums.phpfreaks.com/topic/81934-solved-replace-whole-string/#findComment-416331 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.