3v4l.org

run code in 300+ PHP versions simultaneously
<?php const EMOJIS = [ "00a9" => [["\u00A9\uFE0F", "\u00A9"], "\uE24E", "\uDBBA\uDF29", ["copyright"], 0, 0, 11, 0], "00ae" => [["\u00AE\uFE0F", "\u00AE"], "\uE24F", "\uDBBA\uDF2D", ["registered"], 0, 1, 11, 0], "203c" => [["\u203C\uFE0F", "\u203C"], "", "\uDBBA\uDF06", ["bangbang"], 0, 2, 15, 0] ]; function parse_emojis(string $string): string { preg_match_all('/(?<match>:.*:)/', $string, $matches, PREG_PATTERN_ORDER); $emojis = $matches['match']; foreach ($emojis as $emoji): $emoji_name = trim($emoji, ':'); foreach (EMOJIS as $key => $value): $names = $value[3]; foreach($names as $name): if ($name == $emoji_name): $string = str_replace($emoji, sprintf('\\u{%s}', $key), $string); break; endif; endforeach; endforeach; endforeach; return $string; } var_dump(parse_emojis(' Ok. Nice :registered: Very very very nice :bangbang: Good. '));
Output for 7.0.0 - 7.0.25, 7.1.0 - 7.1.20, 7.2.6 - 7.2.33, 7.3.16 - 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.18, 8.3.0 - 8.3.4, 8.3.6
string(66) " Ok. Nice \u{00ae} Very very very nice \u{203c} Good. "
Output for 8.3.5
Warning: PHP Startup: Unable to load dynamic library 'sodium.so' (tried: /usr/lib/php/8.3.5/modules/sodium.so (libsodium.so.23: cannot open shared object file: No such file or directory), /usr/lib/php/8.3.5/modules/sodium.so.so (/usr/lib/php/8.3.5/modules/sodium.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0 string(66) " Ok. Nice \u{00ae} Very very very nice \u{203c} Good. "

preferences:
195.59 ms | 402 KiB | 180 Q