Porl123 Posted September 25, 2008 Share Posted September 25, 2008 I have a bbcode function with this in it: <?php $string = str_replace("[img]http://","<img src=\"", $string); $string = str_replace("[[b][/b]/img]","\" />", $string); ?> and I've trying to have it so when somebody uses the [/img] there's my image link checking function inside. So something like <img src="".check_image($link)."" /> if it was straight forward, but I'm not sure how I'd do that if the image tags were separate like mine If you know how I'd get around this it'd be much appreciated Link to comment https://forums.phpfreaks.com/topic/125766-functions-inside-str_replace/ Share on other sites More sharing options...
Porl123 Posted September 25, 2008 Author Share Posted September 25, 2008 Damn, it cut off the first line $string = str_replace("","<img src=\"", $string); There's that too Link to comment https://forums.phpfreaks.com/topic/125766-functions-inside-str_replace/#findComment-650333 Share on other sites More sharing options...
asmith Posted September 25, 2008 Share Posted September 25, 2008 Can you be clear more ? What exactly do you want? Link to comment https://forums.phpfreaks.com/topic/125766-functions-inside-str_replace/#findComment-650353 Share on other sites More sharing options...
aschk Posted September 25, 2008 Share Posted September 25, 2008 The problem you have with your code at the minute appears to be closing the img tag. From what i can see you'll write out the <img src="myimage.jpg bit, but you're not closing the tag. You need to get the end position to close the tag. Also with regards to calling a function, something like $string = str_replace("[img]","<img src=\"", check_image($link) ); $string = str_replace("[/img]", "/>", $string); Or something along those lines... the problem here is that we can't see what variables $link, $string, etc start off as, thus rendering our solution rather m00t until we see more code. Link to comment https://forums.phpfreaks.com/topic/125766-functions-inside-str_replace/#findComment-650358 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.