changes made to comply with e modifier error to use preg_replace_callback instead of preg_replace