Forum Moderators: coopster
How to make regexp command in PHP there paste code target="blank" on every link (include image links to) in text (whole text is in one variable).
-------------
refine (not neccesary) if target="blank" already exist skip it.
Lets go! ;)
[edited by: eelixduppy at 8:44 pm (utc) on May 23, 2007]
[edit reason] spelling [/edit]
$string = 'your html here';
$pattern = "/<(aŠimg)([^>]+)>/i";
$replacement = "<\\1 target=\"_blank\"\\2>";
$new_str = preg_replace($pattern,$replacement,str_replace('target="_blank"','',$string));
Try something like that :) Refer to pattern syntax [us.php.net] for more information. Also, make sure to replace the 'Š' with the solid pipe character as webmasterworld breaks these.