RSS
 

how to remove link from certain string?

16 Jun

Some day, I worked on small piece of programming to tweak Virtuemart feature. The task is to remove link in product title of the product detail. as we know, array variable of product in the flypage.tpl.php or flypage.pbv.tpl.php is not containing ‘pure’ data. it contain some html tag that embedded in the previous process.

To follow good work and to keep virtuemart engine in the original state, I have to modify only on the template. so to remove link from $product['product_title'], I use this code:

echo preg_replace(“/\<a([^>]*)\>([^<]*)\<\/a\>/i”, “$2″, $product['product_title']);

Keep in mind that we can replace link from string using this code:

preg_replace("/\<a(.*)\>(.*)\<\/a\>/iU", "$2", $string);

or:

preg_replace("/\<a([^>]*)\>([^<]*)\<\/a\>/i", "$2", $string);
preg_replace("/\<a(.*)\>(.*)\<\/a\>/iU", "$2", $string);
 
 

Leave a Reply

 
 
  1. Sinan Gunay

    August 9, 2010 at 2:24 am

    This guy rocks! Brother you are really good coder. I’m very satisfied and honoured by working and meeting with you! Thank you very much..