Library allows to detect emoji, remove emoji, encode emoji and decode emoji in string.

Overview

It allows to detect emoji, remove emoji, encode emoji and decode emoji in string.

Installation

composer require anisimov/emoji

How to use

Encode and decode Emoji

Single colon delimiter

$delimiter = new \Anisimov\Emoji\Delimiter\SingleColonDelimiter();
$emoji = new \Anisimov\Emoji\Emoji($delimiter);

$stringWithEmoji = 'some string πŸ˜‰';

$result = $emoji->encode($stringWithEmoji); // some string :wink:

$stringWithEncodedEmoji = 'some string :wink:';

$result = $emoji->decode($stringWithEmoji); // some string πŸ˜‰

Double colon delimiter

$delimiter = new \Anisimov\Emoji\Delimiter\DoubleColonDelimiter();
$emoji = new \Anisimov\Emoji\Emoji($delimiter);

$stringWithEmoji = 'some string πŸ˜‰';

$result = $emoji->encode($stringWithEmoji); // some string ::wink::

$stringWithEncodedEmoji = 'some string ::wink::';

$result = $emoji->decode($stringWithEmoji); // some string πŸ˜‰

Triple colon delimiter

$delimiter = new \Anisimov\Emoji\Delimiter\TripleColonDelimiter();
$emoji = new \Anisimov\Emoji\Emoji($delimiter);

$stringWithEmoji = 'some string πŸ˜‰';

$result = $emoji->encode($stringWithEmoji); // some string :::wink:::

$stringWithEncodedEmoji = 'some string :::wink:::';

$result = $emoji->decode($stringWithEmoji); // some string πŸ˜‰

Detect emoji in string

$delimiter = new \Anisimov\Emoji\Delimiter\SingleColonDelimiter();
$emoji = new \Anisimov\Emoji\Emoji($delimiter);

$stringWithEmoji = 'some string πŸ˜‰';

$result = $emoji->hasEmoji($stringWithEmoji); // true

$stringWithoutEmoji = 'some string';

$result = $emoji->hasEmoji($stringWithoutEmoji); // false

Remove all emoji in string

$delimiter = new \Anisimov\Emoji\Delimiter\SingleColonDelimiter();
$emoji = new \Anisimov\Emoji\Emoji($delimiter);

$stringWithEmoji = 'πŸ˜‰ some πŸ˜‰ πŸ˜‰ πŸ˜‰ string πŸ˜‰';

$result = $emoji->remove($stringWithEmoji); // 'some string'

Find all emoji in string

$delimiter = new \Anisimov\Emoji\Delimiter\SingleColonDelimiter();
$emoji = new \Anisimov\Emoji\Emoji($delimiter);

$stringWithEmoji = 'πŸ˜€ some πŸ˜ƒ πŸ˜„ string 😁 πŸ˜†';

$result = $emoji->find($stringWithEmoji); // ['πŸ˜€', 'πŸ˜ƒ', 'πŸ˜„', '😁', 'πŸ˜†']

How to create custom delimiter

Create delimiter class that implements \Anisimov\Emoji\Delimiter\DelimiterInterface.

\Anisimov\Emoji\Delimiter\DelimiterInterface::getRegexp method should return regex to find delimiter wrapped emoji.

\Anisimov\Emoji\Delimiter\DelimiterInterface::getDelimiter method should return delimiter symbols

For example, \Anisimov\Emoji\Delimiter\SingleColonDelimiter

\Anisimov\Emoji\Delimiter\SingleColonDelimiter::getRegexp returns /[\:]{1}[^(\:|\s)]{1,}[\:]{1}/

\Anisimov\Emoji\Delimiter\SingleColonDelimiter::getDelimiter returns :

You might also like...
A PHP Emoji conversion library

php-emoji - Process Emoji in PHP This is a PHP library for dealing with Emoji, allowing you to convert between various native formats and displaying t

Rules to detect game engines and other technologies based on Steam depot file lists

SteamDB File Detection Rule Sets This is a set of scripts that are used by SteamDB to make educated guesses about the engine(s) & technology used to b

Helps detect the user's browser and platform at the PHP level via the user agent

cbschuld/browser.php Helps detect the user's browser and platform at the PHP level via the user agent Installation You can add this library as a local

Mobile detect change theme and redirect based on device type. Magento 2 module.

Magento 2 Mobile Detect Theme Change Magento 2 Mobile detect system can be used to load different themes base on the client device (desktop, tablet, m

The Hoa\String library (deprecated by Hoa\Ustring).

Hoa is a modular, extensible and structured set of PHP libraries. Moreover, Hoa aims at being a bridge between industrial and research worlds. Hoa\Str

Stringy - A PHP string manipulation library with multibyte support, performance optimized

Stringy - A PHP string manipulation library with multibyte support, performance optimized

Detect flaws in your architecture, before they drag you down into the depths of dependency hell ...
Detect flaws in your architecture, before they drag you down into the depths of dependency hell ...

Detect flaws in your architecture before they drag you down into the depths of dependency hell ... What it does System Requirements Installation Phive

Tool to detect assumptions

PHP Assumptions Setup $ composer require --dev rskuipers/php-assumptions Introduction PHP Assumptions is the result of a proof of concept inspired by

The main scope of this extension is to help phpstan to detect the type of object after the Assert\Assertion validation.

PHPStan beberlei/assert extension PHPStan beberlei/assert Description The main scope of this extension is to help phpstan to detect the type of object

Owner
Aleksey Anisimov
Aleksey Anisimov
YCOM Impersonate. Login as selected YCOM user πŸ§™β€β™‚οΈin frontend.

YCOM Impersonate Login as selected YCOM user in frontend. Features: Backend users with admin rights or YCOM[] rights, can be automatically logged in v

Friends Of REDAXO 17 Sep 12, 2022
Php library for converting emoji shortcodes to emoji

Emojify provides methods for checking if string is shortcode replace shortcode with emoji replacing all shortcodes in string with emoji Made for a md

Neo Lejondahl 2 Oct 3, 2022
PHP Japanese string helper functions for converting Japanese strings from full-width to half-width and reverse. Laravel Rule for validation Japanese string only full-width or only half-width.

Japanese String Helpers PHP Japanese string helper functions for converting Japanese strings from full-width to half-width and reverse. Laravel Rule f

Deha 54 Mar 22, 2022
PHP Simple M3U Parser, it clean the playlist and remove duplicate

SimpleM3UParser PHP Simple M3U Playlist Parser, it clean, remove duplicate, and group the playlist. Usage see example.php <?php require_once "M3UPars

erwin solihin 3 May 30, 2022
StickWithIt is an online food ordering website created using PHP. You can view and purchase various items as well as remove items from the cart.

StickWithIt (App Name) StickWithIt is an online food ordering website created using PHP. The database used here is MYSQL database. The tool used here

Jenil Gajjar 1 May 11, 2022
Tool to remove code based on specific comments.

PHP-DEL Tool to remove code based on specific comments. Configuration Create php-del.json in the root directory of the project { "dirs": [ "src"

KenjiroKubota 16 Dec 25, 2022
This plugin help us to remove the unused file or directories in vendor

Composer Ignore Plugin This plugin help us to remove the unused file or directories in vendor. Installation Both global or local install can work well

__FresHmaN 21 Oct 21, 2021
Miniset allows you to create compact sets of fields that either combine into a string of classes, or return a simple array of values

Miniset allows you to create compact sets of fields that either combine into a string of classes, or return a simple array of values. Miniset

Jack Sleight 5 Jun 13, 2022
Library for PHP 7.4+ to detect Browsers and Devices

This library requires PHP 7.4+. Also a PSR-3 compatible logger and a PSR-16 compatible cache are required. In

Thomas MΓΌller 37 Oct 2, 2022
emoji library for PHP.

PHPemoji emoji library for PHP Install composer require amirshnll/php-pemoji Usage code require("PHPemoji.php"); $emoji = new PHPemoji(); echo "Hello

Amir Shokri 5 Jan 28, 2022