Skip to content

Instantly share code, notes, and snippets.

@donwilson
Created February 12, 2019 19:04
Show Gist options
  • Save donwilson/3f4b8abf7e9ea144df030deff0316e8a to your computer and use it in GitHub Desktop.
Save donwilson/3f4b8abf7e9ea144df030deff0316e8a to your computer and use it in GitHub Desktop.
function to strip zalgo/"scary" text from regular strings
<?php
// zalgo text/scary text stripper
// https://stackoverflow.com/a/32921891/103337
function strip_utf8_zalgo_text($string="") {
$string = preg_replace("~(?:[\p{M}]{1})([\p{M}])+?~uis", "", $string);
return $string;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment