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 :ghost: Very very very nice :sunglasses: Good. '));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/d5nbB
function name:  (null)
number of ops:  8
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   DECLARE_CONST                                            'EMOJIS', <array>
   37     1        INIT_FCALL                                               'var_dump'
          2        INIT_FCALL                                               'parse_emojis'
          3        SEND_VAL                                                 '%0A%09%09Ok.%0A%0A%09%09Nice+%3Aghost%3A%0A%0A%09%09Very+very+very+nice+%3Asunglasses%3A%0A%0A%09%09Good.%0A%09'
          4        DO_FCALL                                      0  $0      
          5        SEND_VAR                                                 $0
          6        DO_ICALL                                                 
   45     7      > RETURN                                                   1

Function parse_emojis:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 10, Position 2 = 42
Branch analysis from position: 10
2 jumps found. (Code = 78) Position 1 = 11, Position 2 = 42
Branch analysis from position: 11
2 jumps found. (Code = 77) Position 1 = 18, Position 2 = 40
Branch analysis from position: 18
2 jumps found. (Code = 78) Position 1 = 19, Position 2 = 40
Branch analysis from position: 19
2 jumps found. (Code = 77) Position 1 = 23, Position 2 = 38
Branch analysis from position: 23
2 jumps found. (Code = 78) Position 1 = 24, Position 2 = 38
Branch analysis from position: 24
2 jumps found. (Code = 43) Position 1 = 26, Position 2 = 37
Branch analysis from position: 26
1 jumps found. (Code = 42) Position 1 = 38
Branch analysis from position: 38
1 jumps found. (Code = 42) Position 1 = 18
Branch analysis from position: 18
Branch analysis from position: 37
1 jumps found. (Code = 42) Position 1 = 23
Branch analysis from position: 23
Branch analysis from position: 38
Branch analysis from position: 38
Branch analysis from position: 40
1 jumps found. (Code = 42) Position 1 = 10
Branch analysis from position: 10
Branch analysis from position: 40
Branch analysis from position: 42
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 42
filename:       /in/d5nbB
function name:  parse_emojis
number of ops:  47
compiled vars:  !0 = $string, !1 = $matches, !2 = $emojis, !3 = $emoji, !4 = $emoji_name, !5 = $value, !6 = $key, !7 = $names, !8 = $name
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    9     0  E >   RECV                                             !0      
   11     1        INIT_FCALL                                               'preg_match_all'
          2        SEND_VAL                                                 '%2F%28%3F%3Cmatch%3E%3A.%2A%3A%29%2F'
          3        SEND_VAR                                                 !0
          4        SEND_REF                                                 !1
          5        SEND_VAL                                                 1
          6        DO_ICALL                                                 
   12     7        FETCH_DIM_R                                      ~10     !1, 'match'
          8        ASSIGN                                                   !2, ~10
   14     9      > FE_RESET_R                                       $12     !2, ->42
         10    > > FE_FETCH_R                                               $12, !3, ->42
   15    11    >   INIT_FCALL                                               'trim'
         12        SEND_VAR                                                 !3
         13        SEND_VAL                                                 '%3A'
         14        DO_ICALL                                         $13     
         15        ASSIGN                                                   !4, $13
   17    16        FETCH_CONSTANT                                   ~15     'EMOJIS'
         17      > FE_RESET_R                                       $16     ~15, ->40
         18    > > FE_FETCH_R                                       ~17     $16, !5, ->40
         19    >   ASSIGN                                                   !6, ~17
   18    20        FETCH_DIM_R                                      ~19     !5, 3
         21        ASSIGN                                                   !7, ~19
   20    22      > FE_RESET_R                                       $21     !7, ->38
         23    > > FE_FETCH_R                                               $21, !8, ->38
   21    24    >   IS_EQUAL                                                 !8, !4
         25      > JMPZ                                                     ~22, ->37
   22    26    >   INIT_FCALL                                               'str_replace'
         27        SEND_VAR                                                 !3
         28        INIT_FCALL                                               'sprintf'
         29        SEND_VAL                                                 '%5Cu%7B%25s%7D'
         30        SEND_VAR                                                 !6
         31        DO_ICALL                                         $23     
         32        SEND_VAR                                                 $23
         33        SEND_VAR                                                 !0
         34        DO_ICALL                                         $24     
         35        ASSIGN                                                   !0, $24
   24    36      > JMP                                                      ->38
   20    37    > > JMP                                                      ->23
         38    >   FE_FREE                                                  $21
   17    39      > JMP                                                      ->18
         40    >   FE_FREE                                                  $16
   14    41      > JMP                                                      ->10
         42    >   FE_FREE                                                  $12
   30    43        VERIFY_RETURN_TYPE                                       !0
         44      > RETURN                                                   !0
   31    45*       VERIFY_RETURN_TYPE                                       
         46*     > RETURN                                                   null

End of function parse_emojis

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
179.8 ms | 1407 KiB | 24 Q