I am trying to make a little program in Php that get a message from a text file (json) and to convert some parts into emojis.
The thing is, I just began php yesterday and since, I didn't find the solution to make it works...
I have this code :
$message = $_GET["message"];
$emojis = array();
echo "{$message}\n";
preg_match("({[A-Z0-9]+})", $message, $emojis);
foreach($emojis as $key => $value) {
echo "{$key} => {$value}\n";
$emoji_string = "\\u".$value;
$emoji_unicode = utf8_encode($emoji_string);
$message = str_replace($value, $emoji_unicode, $message);
}
echo "{$message}\n";
So what I am trying to achieve is, by using this regex (\\u{[A-Z0-9]+})
, created on Regex101, I would like to transform a simple unicode text into a emoji in order to display a beautiful message haha
So far, I understand that \u{270B}
#RaisedHand is only one char at the end, so that's why I try to convert my string into a simple char. Am I wrong? However, the code is wrong since I have "\\u{270B}"
instead of "\u{270B}"
...
I am really out of idea for the moment about that, any idea on your side?
Thanks for any help !
Max
Edit 1
I tried with this message: Hey what's up? {270B}
output:
PHP
debug start
Hey what's up? {270B}
0 => {270B}
Hey what's up? \u{270B}
debug done