Skip to content

Instantly share code, notes, and snippets.

@jhonsore
Created June 29, 2019 18:59
Show Gist options
  • Save jhonsore/37db329655ea7cada597e00b4b90d2d5 to your computer and use it in GitHub Desktop.
Save jhonsore/37db329655ea7cada597e00b4b90d2d5 to your computer and use it in GitHub Desktop.
Replace non alphanum and - from php string
$str = '123 - *&ˆ%$#@ T+=esteJhon#4255%%';
$newStr = preg_replace('/[^[:alnum:]-]/','',$str);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment