My Add articles section allow user to formatted input or insert picture

such as when type

[Bold] Hello [/Bold] result is Hello
[Under] Hello again [/Under] result is Hello again

and when user want to add image in articles, First, user upload image to temp folder in server and I use PHP to generate code and user can push code where he want to add picture such as

[pic="5489.gif"]

user can post many image and can formatted font

PHP Code:
[pic="1235.jpg"]
[
BoldHello world [/Bold]
PHP is a server-sidecross-platformHTML embedded scripting language
[pic="4586.gif"][pic="4586.gif"
User type this code in textarea and I keep in single variable $articles and I keey value of $articles in database as Text, the problem is I want also keep all image that user add in database, but I don't how to take each picture name that in $articles.

Can anyone help me?
Is right way to keep all image file in to array and add to database later?