Hi , Need somebody help I have content and in that content there are some links to another website. I need to remove those links , but not all of them only to specific website I think the best is to use preg_replace , but not sure how the pattern would looks exactly. I would really appreciate your help.Thank you very much.
More detailed Example: Text: Without much effort, you can be <a href='yahoo.com'>Yahoo is the easy hosting</a> a master of disguise today. You don't even need to put on a costume or mask. However you see yourself, others will see you that way too. You appear busier than <a href='google.com'>Google is big engine</a>you actually are now because it helps you to avoid taking on additional work. Instead of putting up a smokescreen of illusion, just set your boundaries by telling others what you can and can't do. Pattern: I need to remove all links contains word Google in url Replace: replace whole link with white space <a href='google.com'>Google is big engine</a> , whole link should be removed not just google
use string strip_tags ( string $str [, string $allowable_tags ] ). http://in.php.net/strip-tags ----------------------------------- Download Free Ebooks Top Interview News
You missed the point completely... <?php $text = "Without much effort, you can be <a href='yahoo.com'>Yahoo is the easy hosting</a> a master of disguise today. You don't even need to put on a costume or mask. However you see yourself, others will see you that <a href='http://somesite.lol.google.com/page.html'>way</a> too. <a href='www.google.com'>Google</a> is big engine. You appear busier than <a href='google.com'>Google is big engine</a> you actually <a href='http://google.com'>Google</a> is big engine are now because it helps you <a href='http://web.google.com'>Google</a> to avoid taking on additional work. Instead of putting up a smokescreen of illusion, just set your boundaries by telling others what you can and can't do."; /** Matches (examples) * http://google.com * google.com * www.google.com * http://web.google.com * http://somesite.lol.google.com/page.html * (Basically any link with google in it) */ preg_match_all( '/(?P<find><a href=\'(?:http:\/\/|ftp:\/\/|https:\/\/)?(?:www\.)?(?:(?:[a-z0-9-_\.])*?)?google(?:[^\']*?)\'>(?P<replace>[^<]*?)<\/a>)/i', $text, $matches, PREG_SET_ORDER ); $find = array() and $replace = array(); foreach ( $matches as $match ) $find[] = $match['find'] and $replace[] = $match['replace']; echo str_replace( $find, $replace, $text ); PHP: If you need any alterations please reply back.