PHP code example of anisimov / emoji

1. Go to this page and download the library: Download anisimov/emoji library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

anisimov / emoji example snippets


$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 😉

$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 😉

$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 😉

$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

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

$stringWithEmoji = '😉 some 😉 😉 😉 string 😉';

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

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

$stringWithEmoji = '😀 some 😃 😄 string 😁 😆';

$result = $emoji->find($stringWithEmoji); // ['😀', '😃', '😄', '😁', '😆']