3v4l.org

run code in 300+ PHP versions simultaneously
<?php $usPhone = '800-000-0010'; $regex = <<<'REGEX' ~ (?: ([1-9]\d)(?=(?:\d{2})?$) # 1: double-digit in last segment |(0) # 2: zero |([1-9]) # 3: single digit ) -? # consume optional delimiter ~x REGEX; $f = new NumberFormatter('en', NumberFormatter::SPELLOUT); echo ltrim( preg_replace_callback( $regex, fn($m) => sprintf( ' %s', array_key_last($m) === 2 ? 'oh' : $f->format(intval($m[0])) ), $usPhone ) );
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/4OtdB
function name:  (null)
number of ops:  20
compiled vars:  !0 = $usPhone, !1 = $regex, !2 = $f
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, '800-000-0010'
    5     1        ASSIGN                                                   !1, '%7E%0A+%28%3F%3A%0A++++%28%5B1-9%5D%5Cd%29%28%3F%3D%28%3F%3A%5Cd%7B2%7D%29%3F%24%29++%23+1%3A+double-digit+in+last+segment%0A++++%7C%280%29+++++++++++++++++++++++%23+2%3A+zero%0A++++%7C%28%5B1-9%5D%29+++++++++++++++++++%23+3%3A+single+digit%0A+%29%0A+-%3F++++++++++++++++++++++++++++%23+consume+optional+delimiter%0A%7Ex'
   16     2        NEW                                              $5      'NumberFormatter'
          3        SEND_VAL_EX                                              'en'
          4        FETCH_CLASS_CONSTANT                             ~6      'NumberFormatter', 'SPELLOUT'
          5        SEND_VAL_EX                                              ~6
          6        DO_FCALL                                      0          
          7        ASSIGN                                                   !2, $5
   18     8        INIT_FCALL                                               'ltrim'
   19     9        INIT_FCALL                                               'preg_replace_callback'
   20    10        SEND_VAR                                                 !1
   21    11        DECLARE_LAMBDA_FUNCTION                          ~9      [0]
         12        BIND_LEXICAL                                             ~9, !2
   26    13        SEND_VAL                                                 ~9
   27    14        SEND_VAR                                                 !0
   19    15        DO_ICALL                                         $10     
   27    16        SEND_VAR                                                 $10
   18    17        DO_ICALL                                         $11     
   27    18        ECHO                                                     $11
   29    19      > RETURN                                                   1


Dynamic Functions:
Dynamic Function 0
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 9, Position 2 = 11
Branch analysis from position: 9
1 jumps found. (Code = 42) Position 1 = 17
Branch analysis from position: 17
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 11
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/4OtdB
function name:  {closure}
number of ops:  21
compiled vars:  !0 = $m, !1 = $f
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   21     0  E >   RECV                                             !0      
          1        BIND_STATIC                                              !1
          2        INIT_FCALL                                               'sprintf'
   22     3        SEND_VAL                                                 '+%25s'
   23     4        INIT_FCALL                                               'array_key_last'
          5        SEND_VAR                                                 !0
          6        DO_ICALL                                         $2      
          7        IS_IDENTICAL                                             $2, 2
          8      > JMPZ                                                     ~3, ->11
   24     9    >   QM_ASSIGN                                        ~4      'oh'
         10      > JMP                                                      ->17
   25    11    >   INIT_METHOD_CALL                                         !1, 'format'
         12        FETCH_DIM_R                                      ~5      !0, 0
         13        CAST                                          4  ~6      ~5
         14        SEND_VAL_EX                                              ~6
         15        DO_FCALL                                      0  $7      
         16        QM_ASSIGN                                        ~4      $7
         17    >   SEND_VAL                                                 ~4
   21    18        DO_ICALL                                         $8      
   25    19      > RETURN                                                   $8
   26    20*     > RETURN                                                   null

End of Dynamic Function 0

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
143.15 ms | 1010 KiB | 17 Q