Use regular expressions. If you are sure that the only []s in the page will be images, then something like this would work:
$text=preg_replace("|[(.*)]|", '<img src="/images/\1">', $text);
and if the text is:
here is a pic: [nice_pic.jpg]
then it would be:
here is a pic: <img src="/images/nice_pic.jpg">
Hope that helps,
Dave