OK, so i have this function:

function BBCode($str) {

//
// Change this (BBCode)
//
$change = array(
'/\[b\](.*?)\[\/b\]/is',
'/\[i\](.*?)\[\/i\]/is',
'/\[u\](.*?)\[\/u\]/is',
'/\[url\=(.*?)\](.*?)\[\/url\]/is',
'/\[url\](.*?)\[\/url\]/is',
'/\[img\=(.*?)\](.*?)\[\/img\]/is',
);

//
// With this (HTML)
//
$with = array(
'<strong>$1</strong>',
'<em>$1</em>',
'<u>$1</u>',
'<a href="$1">$2</a>',
'<a href="$1">$1</a>',

);

// Replace
$str = preg_replace($change, $with, $str);

return $str;
}


which replaces the imput with actual code so users could post links, make it bold, italic and other stuff, this is commonly called the "BBCode allowed"

how can i change this so that users can also insert images?