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! Quote 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. Quote 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. Quote 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
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.