Migrate to preg_replace_callback for this