Jump to content

[SOLVED] Call a function while using preg_replace is it posible?


thehigherentity

Recommended Posts

Im trying to update my BBCode function so it will check links and emails have the current beginnings eg mailto:, http:// etc

What I would like to know is how i can add a function into the following so the $1 is checked my my fix_url() function.

 

$str = ' My wbsite '; // my link

$str = preg_replace('/\[url\=(.*?)\](.*?)\[\/url\]/is', '<a href="$1">$2</a>', $str);

 

I have tried changing the code to the following and many versions of it with no luck!

 

$str = ' My wbsite '; // my link

$str = preg_replace('/\[url\=(.*?)\](.*?)\[\/url\]/is', '<a href="'.fix_url('$1').'">$2</a>', $str);

 

If It cant be done this way could someone please point me in the right direction to another way I could do the same type of thing.

 

Thanks in advance

 

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.