$img = '<img src="path/to/images/'.mt_rand(1, 40).'.gif" alt="" />'; $this->post['message'] = str_ireplace('[picturenumber]', $img, $this->post['message']);