PHP function to apply BBCode