3v4l.org

run code in 300+ PHP versions simultaneously
<?php function emoji_to_unicode($emoji) { if (mb_ord($emoji) < 256) return $emoji; $emoji = mb_convert_encoding($emoji, 'UTF-32', 'UTF-8'); $unicode = strtoupper(preg_replace("/^[0]{3}/","U+",bin2hex($emoji))); return $unicode; } $var = ("😀x😀hello"); $out = ''; for ($i = 0; $i < mb_strlen($var); $i++) { $out .= emoji_to_unicode(mb_substr($var, $i, 1)); } echo "$out\n";
Output for 7.2.0 - 7.2.34, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.19, 8.3.0 - 8.3.7
U+1F600xU+1F600hello
Output for 7.1.0 - 7.1.33
Fatal error: Uncaught Error: Call to undefined function mb_ord() in /in/bPcGC:4 Stack trace: #0 /in/bPcGC(14): emoji_to_unicode('\xF0\x9F\x98\x80') #1 {main} thrown in /in/bPcGC on line 4
Process exited with code 255.

preferences:
169.76 ms | 402 KiB | 227 Q