3v4l.org

run code in 300+ PHP versions simultaneously
<?php $price = '10.156'; $price = str_replace(',', '', $price); $price = str_replace('.', ',', $price); // print ($price); print (strpos($price, ",")); if (strpos($price, ',') !== false) { $nbchardecim = strlen(substr($price, strpos($price, ",") + 1)) ; if ($nbchardecim > 2) { $price = substr($price, 0,strlen($price)- $nbchardecim+2); } } print ($price);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 24, Position 2 = 46
Branch analysis from position: 24
2 jumps found. (Code = 43) Position 1 = 37, Position 2 = 46
Branch analysis from position: 37
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 46
Branch analysis from position: 46
filename:       /in/hFaoj
function name:  (null)
number of ops:  48
compiled vars:  !0 = $price, !1 = $nbchardecim
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, '10.156'
    4     1        INIT_FCALL                                               'str_replace'
          2        SEND_VAL                                                 '%2C'
          3        SEND_VAL                                                 ''
          4        SEND_VAR                                                 !0
          5        DO_ICALL                                         $3      
          6        ASSIGN                                                   !0, $3
    5     7        INIT_FCALL                                               'str_replace'
          8        SEND_VAL                                                 '.'
          9        SEND_VAL                                                 '%2C'
         10        SEND_VAR                                                 !0
         11        DO_ICALL                                         $5      
         12        ASSIGN                                                   !0, $5
    7    13        INIT_FCALL                                               'strpos'
         14        SEND_VAR                                                 !0
         15        SEND_VAL                                                 '%2C'
         16        DO_ICALL                                         $7      
         17        ECHO                                                     $7
    9    18        INIT_FCALL                                               'strpos'
         19        SEND_VAR                                                 !0
         20        SEND_VAL                                                 '%2C'
         21        DO_ICALL                                         $8      
         22        TYPE_CHECK                                  1018          $8
         23      > JMPZ                                                     ~9, ->46
   11    24    >   INIT_FCALL                                               'substr'
         25        SEND_VAR                                                 !0
         26        INIT_FCALL                                               'strpos'
         27        SEND_VAR                                                 !0
         28        SEND_VAL                                                 '%2C'
         29        DO_ICALL                                         $10     
         30        ADD                                              ~11     $10, 1
         31        SEND_VAL                                                 ~11
         32        DO_ICALL                                         $12     
         33        STRLEN                                           ~13     $12
         34        ASSIGN                                                   !1, ~13
   12    35        IS_SMALLER                                               2, !1
         36      > JMPZ                                                     ~15, ->46
   14    37    >   INIT_FCALL                                               'substr'
         38        SEND_VAR                                                 !0
         39        SEND_VAL                                                 0
         40        STRLEN                                           ~16     !0
         41        SUB                                              ~17     ~16, !1
         42        ADD                                              ~18     ~17, 2
         43        SEND_VAL                                                 ~18
         44        DO_ICALL                                         $19     
         45        ASSIGN                                                   !0, $19
   17    46    >   ECHO                                                     !0
         47      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
177.05 ms | 1400 KiB | 19 Q