Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Force PDF links to open in a new tab in PHP.
$new_text = preg_replace(
'/((<a (?=.*\.pdf)(?!.*target="_blank").*?)>)/',
'$2 target="_blank">',
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.