PHP code example of chefkoch / morphoji
1. Go to this page and download the library: Download chefkoch/morphoji 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/ */
chefkoch / morphoji example snippets
$text = '...'; // Some text with unicode emojis.
$converter = new \Chefkoch\Morphoji\Converter();
// From utf-8 text to db.
$textForDb = $converter->fromEmojis($text);
$db->insert($textForDb); // Dummy code for DB insert command.
// From db to utf-8 text.
$textWithEmoji = $converter->toEmojis($db->getTextWithPlaceholders());
return new Response($textWithEmoji); // Dummy code for HTML response to browser.
$placeholderText = 'Lorem :emoji-12345: ipsum';
$converter = new \Chefkoch\Morphoji\Converter();
$wrapped = $converter->wrap($placeholderText, ' ');
// results in $wrapped == 'Lorem <span class="emoji" data-emoji-code="12345"> </span> ipsum'