Use preg_replace_callback instead of /e modifier