3v4l.org

run code in 300+ PHP versions simultaneously
<?php $formatter = new \NumberFormatter('de_CH', \NumberFormatter::CURRENCY); $format = $formatter->getPattern(); #$decimalSymbol = $formatter->getSymbol(\NumberFormatter::DECIMAL_SEPARATOR_SYMBOL); #$groupSymbol = $formatter->getSymbol(\NumberFormatter::GROUPING_SEPARATOR_SYMBOL); #echo $format . ' ' . $decimalSymbol . ' ' . $groupSymbol; $r = form($format); var_dump($r); function form($format) { $pos = strpos($format, ';'); if ($pos !== false) { $format = substr($format, 0, $pos); } $format = preg_replace("/[^0\#\.,]/", "", $format); $totalPrecision = 0; $decimalPoint = strpos($format, '.'); if ($decimalPoint !== false) { $totalPrecision = strlen($format) - (strrpos($format, '.') + 1); } else { $decimalPoint = strlen($format); } $requiredPrecision = $totalPrecision; $t = substr($format, $decimalPoint); $pos = strpos($t, '#'); if ($pos !== false) { $requiredPrecision = strlen($t) - $pos - $totalPrecision; } if (strrpos($format, ',') !== false) { $group = $decimalPoint - strrpos($format, ',') - 1; } else { $group = strrpos($format, '.'); } $integerRequired = strpos($format, '.') - strpos($format, '0'); return [ 'requiredPrecision' => $requiredPrecision, 'group' => $group, 'integerRequired' => $integerRequired ]; }
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/kvlYn
function name:  (null)
number of ops:  17
compiled vars:  !0 = $formatter, !1 = $format, !2 = $r
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   NEW                                              $3      'NumberFormatter'
          1        SEND_VAL_EX                                              'de_CH'
          2        FETCH_CLASS_CONSTANT                             ~4      'NumberFormatter', 'CURRENCY'
          3        SEND_VAL_EX                                              ~4
          4        DO_FCALL                                      0          
          5        ASSIGN                                                   !0, $3
    4     6        INIT_METHOD_CALL                                         !0, 'getPattern'
          7        DO_FCALL                                      0  $7      
          8        ASSIGN                                                   !1, $7
    9     9        INIT_FCALL_BY_NAME                                       'form'
         10        SEND_VAR_EX                                              !1
         11        DO_FCALL                                      0  $9      
         12        ASSIGN                                                   !2, $9
   10    13        INIT_FCALL                                               'var_dump'
         14        SEND_VAR                                                 !2
         15        DO_ICALL                                                 
   44    16      > RETURN                                                   1

Function form:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 8, Position 2 = 14
Branch analysis from position: 8
2 jumps found. (Code = 43) Position 1 = 28, Position 2 = 37
Branch analysis from position: 28
1 jumps found. (Code = 42) Position 1 = 39
Branch analysis from position: 39
2 jumps found. (Code = 43) Position 1 = 52, Position 2 = 56
Branch analysis from position: 52
2 jumps found. (Code = 43) Position 1 = 62, Position 2 = 70
Branch analysis from position: 62
1 jumps found. (Code = 42) Position 1 = 75
Branch analysis from position: 75
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 70
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 56
Branch analysis from position: 37
2 jumps found. (Code = 43) Position 1 = 52, Position 2 = 56
Branch analysis from position: 52
Branch analysis from position: 56
Branch analysis from position: 14
filename:       /in/kvlYn
function name:  form
number of ops:  90
compiled vars:  !0 = $format, !1 = $pos, !2 = $totalPrecision, !3 = $decimalPoint, !4 = $requiredPrecision, !5 = $t, !6 = $group, !7 = $integerRequired
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   13     0  E >   RECV                                             !0      
   14     1        INIT_FCALL                                               'strpos'
          2        SEND_VAR                                                 !0
          3        SEND_VAL                                                 '%3B'
          4        DO_ICALL                                         $8      
          5        ASSIGN                                                   !1, $8
   15     6        TYPE_CHECK                                  1018          !1
          7      > JMPZ                                                     ~10, ->14
   16     8    >   INIT_FCALL                                               'substr'
          9        SEND_VAR                                                 !0
         10        SEND_VAL                                                 0
         11        SEND_VAR                                                 !1
         12        DO_ICALL                                         $11     
         13        ASSIGN                                                   !0, $11
   18    14    >   INIT_FCALL                                               'preg_replace'
         15        SEND_VAL                                                 '%2F%5B%5E0%5C%23%5C.%2C%5D%2F'
         16        SEND_VAL                                                 ''
         17        SEND_VAR                                                 !0
         18        DO_ICALL                                         $13     
         19        ASSIGN                                                   !0, $13
   19    20        ASSIGN                                                   !2, 0
   20    21        INIT_FCALL                                               'strpos'
         22        SEND_VAR                                                 !0
         23        SEND_VAL                                                 '.'
         24        DO_ICALL                                         $16     
         25        ASSIGN                                                   !3, $16
   21    26        TYPE_CHECK                                  1018          !3
         27      > JMPZ                                                     ~18, ->37
   22    28    >   STRLEN                                           ~19     !0
         29        INIT_FCALL                                               'strrpos'
         30        SEND_VAR                                                 !0
         31        SEND_VAL                                                 '.'
         32        DO_ICALL                                         $20     
         33        ADD                                              ~21     $20, 1
         34        SUB                                              ~22     ~19, ~21
         35        ASSIGN                                                   !2, ~22
         36      > JMP                                                      ->39
   24    37    >   STRLEN                                           ~24     !0
         38        ASSIGN                                                   !3, ~24
   26    39    >   ASSIGN                                                   !4, !2
   27    40        INIT_FCALL                                               'substr'
         41        SEND_VAR                                                 !0
         42        SEND_VAR                                                 !3
         43        DO_ICALL                                         $27     
         44        ASSIGN                                                   !5, $27
   28    45        INIT_FCALL                                               'strpos'
         46        SEND_VAR                                                 !5
         47        SEND_VAL                                                 '%23'
         48        DO_ICALL                                         $29     
         49        ASSIGN                                                   !1, $29
   29    50        TYPE_CHECK                                  1018          !1
         51      > JMPZ                                                     ~31, ->56
   30    52    >   STRLEN                                           ~32     !5
         53        SUB                                              ~33     ~32, !1
         54        SUB                                              ~34     ~33, !2
         55        ASSIGN                                                   !4, ~34
   33    56    >   INIT_FCALL                                               'strrpos'
         57        SEND_VAR                                                 !0
         58        SEND_VAL                                                 '%2C'
         59        DO_ICALL                                         $36     
         60        TYPE_CHECK                                  1018          $36
         61      > JMPZ                                                     ~37, ->70
   34    62    >   INIT_FCALL                                               'strrpos'
         63        SEND_VAR                                                 !0
         64        SEND_VAL                                                 '%2C'
         65        DO_ICALL                                         $38     
         66        SUB                                              ~39     !3, $38
         67        SUB                                              ~40     ~39, 1
         68        ASSIGN                                                   !6, ~40
         69      > JMP                                                      ->75
   36    70    >   INIT_FCALL                                               'strrpos'
         71        SEND_VAR                                                 !0
         72        SEND_VAL                                                 '.'
         73        DO_ICALL                                         $42     
         74        ASSIGN                                                   !6, $42
   38    75    >   INIT_FCALL                                               'strpos'
         76        SEND_VAR                                                 !0
         77        SEND_VAL                                                 '.'
         78        DO_ICALL                                         $44     
         79        INIT_FCALL                                               'strpos'
         80        SEND_VAR                                                 !0
         81        SEND_VAL                                                 '0'
         82        DO_ICALL                                         $45     
         83        SUB                                              ~46     $44, $45
         84        ASSIGN                                                   !7, ~46
   40    85        INIT_ARRAY                                       ~48     !4, 'requiredPrecision'
   41    86        ADD_ARRAY_ELEMENT                                ~48     !6, 'group'
   42    87        ADD_ARRAY_ELEMENT                                ~48     !7, 'integerRequired'
         88      > RETURN                                                   ~48
   44    89*     > RETURN                                                   null

End of function form

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
161.24 ms | 1396 KiB | 23 Q