3v4l.org

run code in 300+ PHP versions simultaneously
<?php function getValorDecimal($linhaDados, $posicaoInicial, $tamanhoCampo, $decimal = 0) { $retorno = ""; $retorno = substr($linhaDados,$posicaoInicial-1 , $tamanhoCampo ); $retorno = trim($retorno); $retorno = str_replace(".","", $retorno); $retorno = str_replace(",",".", $retorno); if ($retorno != "") { $retorno = ltrim($retorno,'0'); if ($retorno == '') { $retorno = '0'; } if ($retorno != 0 && $decimal != 0) { $divisor = str_pad('1', $decimal + 1, '0'); $retorno = round($retorno / $divisor , $decimal); } } return $retorno; } $v = getValorDecimal('000000015565835', 1, 15, 2); echo str_replace(".",",", $v);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/KcgtP
function name:  (null)
number of ops:  14
compiled vars:  !0 = $v
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   23     0  E >   INIT_FCALL                                               'getvalordecimal'
          1        SEND_VAL                                                 '000000015565835'
          2        SEND_VAL                                                 1
          3        SEND_VAL                                                 15
          4        SEND_VAL                                                 2
          5        DO_FCALL                                      0  $1      
          6        ASSIGN                                                   !0, $1
   24     7        INIT_FCALL                                               'str_replace'
          8        SEND_VAL                                                 '.'
          9        SEND_VAL                                                 '%2C'
         10        SEND_VAR                                                 !0
         11        DO_ICALL                                         $3      
         12        ECHO                                                     $3
         13      > RETURN                                                   1

Function getvalordecimal:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 30, Position 2 = 56
Branch analysis from position: 30
2 jumps found. (Code = 43) Position 1 = 37, Position 2 = 38
Branch analysis from position: 37
2 jumps found. (Code = 46) Position 1 = 40, Position 2 = 42
Branch analysis from position: 40
2 jumps found. (Code = 43) Position 1 = 43, Position 2 = 56
Branch analysis from position: 43
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 56
Branch analysis from position: 42
Branch analysis from position: 38
Branch analysis from position: 56
filename:       /in/KcgtP
function name:  getValorDecimal
number of ops:  58
compiled vars:  !0 = $linhaDados, !1 = $posicaoInicial, !2 = $tamanhoCampo, !3 = $decimal, !4 = $retorno, !5 = $divisor
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        RECV                                             !2      
          3        RECV_INIT                                        !3      0
    3     4        ASSIGN                                                   !4, ''
    5     5        INIT_FCALL                                               'substr'
          6        SEND_VAR                                                 !0
          7        SUB                                              ~7      !1, 1
          8        SEND_VAL                                                 ~7
          9        SEND_VAR                                                 !2
         10        DO_ICALL                                         $8      
         11        ASSIGN                                                   !4, $8
    6    12        INIT_FCALL                                               'trim'
         13        SEND_VAR                                                 !4
         14        DO_ICALL                                         $10     
         15        ASSIGN                                                   !4, $10
    7    16        INIT_FCALL                                               'str_replace'
         17        SEND_VAL                                                 '.'
         18        SEND_VAL                                                 ''
         19        SEND_VAR                                                 !4
         20        DO_ICALL                                         $12     
         21        ASSIGN                                                   !4, $12
    8    22        INIT_FCALL                                               'str_replace'
         23        SEND_VAL                                                 '%2C'
         24        SEND_VAL                                                 '.'
         25        SEND_VAR                                                 !4
         26        DO_ICALL                                         $14     
         27        ASSIGN                                                   !4, $14
   10    28        IS_NOT_EQUAL                                             !4, ''
         29      > JMPZ                                                     ~16, ->56
   11    30    >   INIT_FCALL                                               'ltrim'
         31        SEND_VAR                                                 !4
         32        SEND_VAL                                                 '0'
         33        DO_ICALL                                         $17     
         34        ASSIGN                                                   !4, $17
   12    35        IS_EQUAL                                                 !4, ''
         36      > JMPZ                                                     ~19, ->38
   13    37    >   ASSIGN                                                   !4, '0'
   15    38    >   IS_NOT_EQUAL                                     ~21     !4, 0
         39      > JMPZ_EX                                          ~21     ~21, ->42
         40    >   IS_NOT_EQUAL                                     ~22     !3, 0
         41        BOOL                                             ~21     ~22
         42    > > JMPZ                                                     ~21, ->56
   16    43    >   INIT_FCALL                                               'str_pad'
         44        SEND_VAL                                                 '1'
         45        ADD                                              ~23     !3, 1
         46        SEND_VAL                                                 ~23
         47        SEND_VAL                                                 '0'
         48        DO_ICALL                                         $24     
         49        ASSIGN                                                   !5, $24
   17    50        INIT_FCALL                                               'round'
         51        DIV                                              ~26     !4, !5
         52        SEND_VAL                                                 ~26
         53        SEND_VAR                                                 !3
         54        DO_ICALL                                         $27     
         55        ASSIGN                                                   !4, $27
   20    56    > > RETURN                                                   !4
   21    57*     > RETURN                                                   null

End of function getvalordecimal

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
171.57 ms | 1403 KiB | 26 Q