Jump to content

Calling function inside preg_replace


Porl123

Recommended Posts

$string = preg_replace('/\[img\](.*?)\[\/img\]/','<img src="'.validImage('\\1').'" />',$string);

 

I'm trying to make the image tags bb code, but I need to put the link through the validImage function to check that it isn't an invalid image. I'm not really sure how to wrap it though. I think the way I've done it above just analyses the literal phrase '\\1' rather than what it represents. Anyone know what I'm doing wrong? Thanks guys!

Link to comment
https://forums.phpfreaks.com/topic/204041-calling-function-inside-preg_replace/
Share on other sites

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.