Skip to content

Instantly share code, notes, and snippets.

@qazd
Created December 17, 2016 05:11
Show Gist options
  • Save qazd/c8883cf3458d4f6b5e6fc806a56a9f1c to your computer and use it in GitHub Desktop.
Save qazd/c8883cf3458d4f6b5e6fc806a56a9f1c to your computer and use it in GitHub Desktop.
Removes unicode characters with length larger than 3 bytes from string
<?php
$string = '🤔 THINKING 🤔 FACE 🤔';
$string = preg_replace_callback('/./u', function (array $match) {
return strlen($match[0]) > 3 ? null : $match[0];
}, $string);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment