Skip to content

Instantly share code, notes, and snippets.

@phpfour
Created January 30, 2021 06:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save phpfour/b6668cb4596436cd2f8db7754bb84279 to your computer and use it in GitHub Desktop.
Save phpfour/b6668cb4596436cd2f8db7754bb84279 to your computer and use it in GitHub Desktop.
A simple removeEmoji function in PHP
<?php
// @see https://stackoverflow.com/a/65179618/196121
function removeEmoji(string $text): string
{
$text = iconv('UTF-8', 'ISO-8859-15//IGNORE', $text);
$text = preg_replace('/\s+/', ' ', $text);
return iconv('ISO-8859-15', 'UTF-8', $text);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment