Capturing [img] tags
Posted: Tue Dec 09, 2008 11:52 am
I've been trying to get my forum to allow [ img ] tags. I want to use ereg_replace to find all strings of type '[ img ]url[ /img ]' and replace them with '< img src="url" />. I tried the command , but it just made it so my posts were empty of all text.
Or would this be much easier if I used a completely different approach?
Note: another plus would be if it could detect if 'url' has no spaces and/or ends in 'jpg', 'png', or 'gif', but right now I'm just going for the basic functionality.
Code: Select all
$post-text = ereg_replace('\[img\]\( \)\[/img\]', '<img src="\1" />', $post-text);Or would this be much easier if I used a completely different approach?
Note: another plus would be if it could detect if 'url' has no spaces and/or ends in 'jpg', 'png', or 'gif', but right now I'm just going for the basic functionality.