3v4l.org

run code in 500+ PHP versions simultaneously
<?php function price_format($num,$type = 1){ $num_full = number_format($num,2); if (strpos($num, '.') !== false) { $num = substr($num_full, 0, strpos($num_full, ".")); } if($type == 1){ // '₹10,00,000.00/-' $explrestunits = "" ; if(strlen($num)>3) { $lastthree = substr($num, strlen($num)-3, strlen($num)); $restunits = substr($num, 0, strlen($num)-3); // extracts the last three digits $restunits = (strlen($restunits)%2 == 1)?"0".$restunits:$restunits; // explodes the remaining digits in 2's formats, adds a zero in the beginning to maintain the 2's grouping. $expunit = str_split($restunits, 2); for($i=0; $i<sizeof($expunit); $i++) { // creates each of the 2's group and adds a comma to the end if($i==0) { $explrestunits .= (int)$expunit[$i].","; // if is first value , convert into integer } else { $explrestunits .= $expunit[$i].","; } } $thecash = "₹".$explrestunits.$lastthree.substr($num_full, -3, strpos($num_full, "."))."/-"; } else { $thecash = "₹".$num.substr($num_full, -3, strpos($num_full, "."))."/-"; } return $thecash; // writes the final format where $currency is the currency symbol. } } echo price_format(1)."<br />"; echo price_format(10)."<br />"; echo price_format(84289.35);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/eNYDl
function name:  (null)
number of ops:  15
compiled vars:  none
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   32     0  E >   INIT_FCALL                                                   'price_format'
          1        SEND_VAL                                                     1
          2        DO_FCALL                                          0  $0      
          3        CONCAT                                               ~1      $0, '%3Cbr+%2F%3E'
          4        ECHO                                                         ~1
   33     5        INIT_FCALL                                                   'price_format'
          6        SEND_VAL                                                     10
          7        DO_FCALL                                          0  $2      
          8        CONCAT                                               ~3      $2, '%3Cbr+%2F%3E'
          9        ECHO                                                         ~3
   34    10        INIT_FCALL                                                   'price_format'
         11        SEND_VAL                                                     84289.4
         12        DO_FCALL                                          0  $4      
         13        ECHO                                                         $4
         14      > RETURN                                                       1

Function price_format:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 10, Position 2 = 14
Branch analysis from position: 10
2 jumps found. (Code = 43) Position 1 = 16, Position 2 = 78
Branch analysis from position: 16
2 jumps found. (Code = 43) Position 1 = 20, Position 2 = 70
Branch analysis from position: 20
2 jumps found. (Code = 43) Position 1 = 35, Position 2 = 38
Branch analysis from position: 35
1 jumps found. (Code = 42) Position 1 = 39
Branch analysis from position: 39
1 jumps found. (Code = 42) Position 1 = 58
Branch analysis from position: 58
2 jumps found. (Code = 44) Position 1 = 61, Position 2 = 47
Branch analysis from position: 61
1 jumps found. (Code = 42) Position 1 = 77
Branch analysis from position: 77
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 47
2 jumps found. (Code = 43) Position 1 = 49, Position 2 = 54
Branch analysis from position: 49
1 jumps found. (Code = 42) Position 1 = 57
Branch analysis from position: 57
2 jumps found. (Code = 44) Position 1 = 61, Position 2 = 47
Branch analysis from position: 61
Branch analysis from position: 47
Branch analysis from position: 54
2 jumps found. (Code = 44) Position 1 = 61, Position 2 = 47
Branch analysis from position: 61
Branch analysis from position: 47
Branch analysis from position: 38
1 jumps found. (Code = 42) Position 1 = 58
Branch analysis from position: 58
Branch analysis from position: 70
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 78
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 14
filename:       /in/eNYDl
function name:  price_format
number of ops:  79
compiled vars:  !0 = $num, !1 = $type, !2 = $num_full, !3 = $explrestunits, !4 = $lastthree, !5 = $restunits, !6 = $expunit, !7 = $i, !8 = $thecash
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    3     0  E >   RECV                                                 !0      
          1        RECV_INIT                                            !1      1
    4     2        INIT_FCALL                                                   'number_format'
          3        SEND_VAR                                                     !0
          4        SEND_VAL                                                     2
          5        DO_ICALL                                             $9      
          6        ASSIGN                                                       !2, $9
    5     7        FRAMELESS_ICALL_2                strpos              ~11     !0, '.'
          8        TYPE_CHECK                                      1018          ~11
          9      > JMPZ                                                         ~12, ->14
    6    10    >   FRAMELESS_ICALL_2                strpos              ~13     !2, '.'
         11        FRAMELESS_ICALL_3                substr              ~14     !2, 0
         12        OP_DATA                                                      ~13
         13        ASSIGN                                                       !0, ~14
    9    14    >   IS_EQUAL                                                     !1, 1
         15      > JMPZ                                                         ~16, ->78
   10    16    >   ASSIGN                                                       !3, ''
   11    17        STRLEN                                               ~18     !0
         18        IS_SMALLER                                                   3, ~18
         19      > JMPZ                                                         ~19, ->70
   12    20    >   STRLEN                                               ~20     !0
         21        SUB                                                  ~21     ~20, 3
         22        STRLEN                                               ~22     !0
         23        FRAMELESS_ICALL_3                substr              ~23     !0, ~21
         24        OP_DATA                                                      ~22
         25        ASSIGN                                                       !4, ~23
   13    26        STRLEN                                               ~25     !0
         27        SUB                                                  ~26     ~25, 3
         28        FRAMELESS_ICALL_3                substr              ~27     !0, 0
         29        OP_DATA                                                      ~26
         30        ASSIGN                                                       !5, ~27
   14    31        STRLEN                                               ~29     !5
         32        MOD                                                  ~30     ~29, 2
         33        IS_EQUAL                                                     ~30, 1
         34      > JMPZ                                                         ~31, ->38
         35    >   CONCAT                                               ~32     '0', !5
         36        QM_ASSIGN                                            ~33     ~32
         37      > JMP                                                          ->39
         38    >   QM_ASSIGN                                            ~33     !5
         39    >   ASSIGN                                                       !5, ~33
   15    40        INIT_FCALL                                                   'str_split'
         41        SEND_VAR                                                     !5
         42        SEND_VAL                                                     2
         43        DO_ICALL                                             $35     
         44        ASSIGN                                                       !6, $35
   16    45        ASSIGN                                                       !7, 0
         46      > JMP                                                          ->58
   18    47    >   IS_EQUAL                                                     !7, 0
         48      > JMPZ                                                         ~38, ->54
   19    49    >   FETCH_DIM_R                                          ~39     !6, !7
         50        CAST                                              4  ~40     ~39
         51        CONCAT                                               ~41     ~40, '%2C'
         52        ASSIGN_OP                                         8          !3, ~41
   18    53      > JMP                                                          ->57
   21    54    >   FETCH_DIM_R                                          ~43     !6, !7
         55        CONCAT                                               ~44     ~43, '%2C'
         56        ASSIGN_OP                                         8          !3, ~44
   16    57    >   PRE_INC                                                      !7
         58    >   COUNT                                                ~47     !6
         59        IS_SMALLER                                                   !7, ~47
         60      > JMPNZ                                                        ~48, ->47
   24    61    >   CONCAT                                               ~49     '%E2%82%B9', !3
         62        CONCAT                                               ~50     ~49, !4
         63        FRAMELESS_ICALL_2                strpos              ~51     !2, '.'
         64        FRAMELESS_ICALL_3                substr              ~52     !2, -3
         65        OP_DATA                                                      ~51
         66        CONCAT                                               ~53     ~50, ~52
         67        CONCAT                                               ~54     ~53, '%2F-'
         68        ASSIGN                                                       !8, ~54
   11    69      > JMP                                                          ->77
   26    70    >   CONCAT                                               ~56     '%E2%82%B9', !0
         71        FRAMELESS_ICALL_2                strpos              ~57     !2, '.'
         72        FRAMELESS_ICALL_3                substr              ~58     !2, -3
         73        OP_DATA                                                      ~57
         74        CONCAT                                               ~59     ~56, ~58
         75        CONCAT                                               ~60     ~59, '%2F-'
         76        ASSIGN                                                       !8, ~60
   28    77    > > RETURN                                                       !8
   30    78    > > RETURN                                                       null

End of function price_format

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
177.84 ms | 1997 KiB | 18 Q