Porl123 Posted June 6, 2010 Share Posted June 6, 2010 $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 More sharing options...
premiso Posted June 6, 2010 Share Posted June 6, 2010 You are going to want to look into the e modifier for the preg functions, as it will do the eval. Link to comment https://forums.phpfreaks.com/topic/204041-calling-function-inside-preg_replace/#findComment-1068707 Share on other sites More sharing options...
Porl123 Posted June 6, 2010 Author Share Posted June 6, 2010 Ah yeah it's sorted now. :] thanks premiso. Link to comment https://forums.phpfreaks.com/topic/204041-calling-function-inside-preg_replace/#findComment-1068710 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.