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); $v = str_replace(".",",", $v); $value = $v; $rsp = ""; if($value != ""){ $arrayVirgula = explode(",",trim($value)); if (count($arrayVirgula) > 1) { $rsp = preg_match("/^[0-9\,]+$/", strip_tags(trim($value))); }else{ $rsp = preg_match("/^[0-9\.]+$/", strip_tags(trim($value))); } } echo $rsp;
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 17, Position 2 = 51
Branch analysis from position: 17
2 jumps found. (Code = 43) Position 1 = 28, Position 2 = 40
Branch analysis from position: 28
1 jumps found. (Code = 42) Position 1 = 51
Branch analysis from position: 51
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 40
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 51
filename:       /in/6lrKM
function name:  (null)
number of ops:  53
compiled vars:  !0 = $v, !1 = $value, !2 = $rsp, !3 = $arrayVirgula
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  $4      
          6        ASSIGN                                                   !0, $4
   24     7        INIT_FCALL                                               'str_replace'
          8        SEND_VAL                                                 '.'
          9        SEND_VAL                                                 '%2C'
         10        SEND_VAR                                                 !0
         11        DO_ICALL                                         $6      
         12        ASSIGN                                                   !0, $6
   26    13        ASSIGN                                                   !1, !0
   27    14        ASSIGN                                                   !2, ''
   28    15        IS_NOT_EQUAL                                             !1, ''
         16      > JMPZ                                                     ~10, ->51
   29    17    >   INIT_FCALL                                               'explode'
         18        SEND_VAL                                                 '%2C'
         19        INIT_FCALL                                               'trim'
         20        SEND_VAR                                                 !1
         21        DO_ICALL                                         $11     
         22        SEND_VAR                                                 $11
         23        DO_ICALL                                         $12     
         24        ASSIGN                                                   !3, $12
   30    25        COUNT                                            ~14     !3
         26        IS_SMALLER                                               1, ~14
         27      > JMPZ                                                     ~15, ->40
   31    28    >   INIT_FCALL                                               'preg_match'
         29        SEND_VAL                                                 '%2F%5E%5B0-9%5C%2C%5D%2B%24%2F'
         30        INIT_FCALL                                               'strip_tags'
         31        INIT_FCALL                                               'trim'
         32        SEND_VAR                                                 !1
         33        DO_ICALL                                         $16     
         34        SEND_VAR                                                 $16
         35        DO_ICALL                                         $17     
         36        SEND_VAR                                                 $17
         37        DO_ICALL                                         $18     
         38        ASSIGN                                                   !2, $18
         39      > JMP                                                      ->51
   33    40    >   INIT_FCALL                                               'preg_match'
         41        SEND_VAL                                                 '%2F%5E%5B0-9%5C.%5D%2B%24%2F'
         42        INIT_FCALL                                               'strip_tags'
         43        INIT_FCALL                                               'trim'
         44        SEND_VAR                                                 !1
         45        DO_ICALL                                         $20     
         46        SEND_VAR                                                 $20
         47        DO_ICALL                                         $21     
         48        SEND_VAR                                                 $21
         49        DO_ICALL                                         $22     
         50        ASSIGN                                                   !2, $22
   37    51    >   ECHO                                                     !2
         52      > 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/6lrKM
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:
156.77 ms | 1407 KiB | 32 Q