Jump to content

[SOLVED] replace whole string


mars_rahul

Recommended Posts

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

$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!

)

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.