3v4l.org

run code in 300+ PHP versions simultaneously
<?php function Price($c,$pid){ //return '0.00'; $p=array(); $mintcard=array(); foreach($c as $comp => $competitor){ $p[] = $competitor['price']; if($comp=='mtgmintcard'){ $mintcard['stock'] = $competitor['stock']; $mintcard['price'] = $competitor['price']; } } if(count($mintcard)===0) return false; $min = _MIN($p); $avg = _AVG($p); if($mintcard['stock']>=1){ switch(true){ case $min <= 0.10: $price = (4 > 35 ? 0.05 : $min); break; case $min > 0.10 && $min < 0.16: $price = bcmul($min,1,2); break; case $min >= 0.16 && $min <= 0.99: $price = bcmul($avg,0.95,2); break; case $min >= 1.00 && $min <= 1.99: $price = bcdiv(bcmul((bcadd($avg,$mintcard['price'],2)),0.95,2),2,2) ; break; // + mtg price case $min >= 2.00: $price = bcmul($min,0.99,2); break; default: $price = false; break; } }else{ //switch(true){ /*case $min <= 0.10: $price = (_SQL_FETCHSTOCK($pid) > 35 ? 0.05 : $min); break; case $min >= 0.10 && $min < 0.16: $price = bcmul($min,0.99,2); break; case $min >= 0.16 && $min <= 0.99: $price = bcmul($avg,0.95,2); break; case $min >= 1.00 : $price = bcdiv(bcmul((bcadd($avg,$mintcard['price'],2)),0.95,2),2,2); break; // + mtg price default: $price = false; break;*/ //} $price = $avg; } return ($mintcard['stock']==-1 ? FoilPrice($price) : $price); } function FoilPrice($price){ switch(true){ case $price <= 1.00: $price = bcmul($price,2.5,2); break; case $price > 1.00 && $price <= 10.00: $price = bcmul($price,2,2); break; case $price > 10.00: $price = bcmul($price,1.5,2); break; } return $price; } function _AVG($args){ /*$count = func_num_args(); $args = func_get_args();*/ $count = count($args); $sum = array_sum($args); echo bcdiv($sum,$count,2); return bcdiv($sum,$count,2); } function _MIN($args){ echo min($args); return min($args); } $c=array( 'mtgmintcard' => array( 'price' => 2.50, 'stock' => '-1' ), 'manaleak' => array( 'price' => 4.99, 'stock' => 5 ), 'magicmadhouse' => array( 'price' => 4.99, 'stock' => 1 ) ); $pid=1; echo Price($c,$pid);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/glGvp
function name:  (null)
number of ops:  8
compiled vars:  !0 = $c, !1 = $pid
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   57     0  E >   ASSIGN                                                   !0, <array>
   71     1        ASSIGN                                                   !1, 1
   72     2        INIT_FCALL                                               'price'
          3        SEND_VAR                                                 !0
          4        SEND_VAR                                                 !1
          5        DO_FCALL                                      0  $4      
          6        ECHO                                                     $4
          7      > RETURN                                                   1

Function price:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 5, Position 2 = 19
Branch analysis from position: 5
2 jumps found. (Code = 78) Position 1 = 6, Position 2 = 19
Branch analysis from position: 6
2 jumps found. (Code = 43) Position 1 = 12, Position 2 = 18
Branch analysis from position: 12
1 jumps found. (Code = 42) Position 1 = 5
Branch analysis from position: 5
Branch analysis from position: 18
Branch analysis from position: 19
2 jumps found. (Code = 43) Position 1 = 23, Position 2 = 24
Branch analysis from position: 23
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 24
2 jumps found. (Code = 43) Position 1 = 35, Position 2 = 104
Branch analysis from position: 35
2 jumps found. (Code = 44) Position 1 = 37, Position 2 = 55
Branch analysis from position: 37
2 jumps found. (Code = 46) Position 1 = 39, Position 2 = 41
Branch analysis from position: 39
2 jumps found. (Code = 44) Position 1 = 42, Position 2 = 61
Branch analysis from position: 42
2 jumps found. (Code = 46) Position 1 = 44, Position 2 = 46
Branch analysis from position: 44
2 jumps found. (Code = 44) Position 1 = 47, Position 2 = 68
Branch analysis from position: 47
2 jumps found. (Code = 46) Position 1 = 49, Position 2 = 51
Branch analysis from position: 49
2 jumps found. (Code = 44) Position 1 = 52, Position 2 = 75
Branch analysis from position: 52
2 jumps found. (Code = 44) Position 1 = 54, Position 2 = 94
Branch analysis from position: 54
1 jumps found. (Code = 42) Position 1 = 101
Branch analysis from position: 101
1 jumps found. (Code = 42) Position 1 = 103
Branch analysis from position: 103
1 jumps found. (Code = 42) Position 1 = 105
Branch analysis from position: 105
2 jumps found. (Code = 43) Position 1 = 108, Position 2 = 113
Branch analysis from position: 108
1 jumps found. (Code = 42) Position 1 = 114
Branch analysis from position: 114
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 113
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 94
1 jumps found. (Code = 42) Position 1 = 103
Branch analysis from position: 103
Branch analysis from position: 75
1 jumps found. (Code = 42) Position 1 = 103
Branch analysis from position: 103
Branch analysis from position: 51
Branch analysis from position: 68
1 jumps found. (Code = 42) Position 1 = 103
Branch analysis from position: 103
Branch analysis from position: 46
Branch analysis from position: 61
1 jumps found. (Code = 42) Position 1 = 103
Branch analysis from position: 103
Branch analysis from position: 41
Branch analysis from position: 55
2 jumps found. (Code = 43) Position 1 = 56, Position 2 = 58
Branch analysis from position: 56
1 jumps found. (Code = 42) Position 1 = 59
Branch analysis from position: 59
1 jumps found. (Code = 42) Position 1 = 103
Branch analysis from position: 103
Branch analysis from position: 58
1 jumps found. (Code = 42) Position 1 = 103
Branch analysis from position: 103
Branch analysis from position: 104
2 jumps found. (Code = 43) Position 1 = 108, Position 2 = 113
Branch analysis from position: 108
Branch analysis from position: 113
Branch analysis from position: 19
filename:       /in/glGvp
function name:  Price
number of ops:  116
compiled vars:  !0 = $c, !1 = $pid, !2 = $p, !3 = $mintcard, !4 = $competitor, !5 = $comp, !6 = $min, !7 = $avg, !8 = $price
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   RECV                                             !0      
          1        RECV                                             !1      
    4     2        ASSIGN                                                   !2, <array>
    5     3        ASSIGN                                                   !3, <array>
    6     4      > FE_RESET_R                                       $11     !0, ->19
          5    > > FE_FETCH_R                                       ~12     $11, !4, ->19
          6    >   ASSIGN                                                   !5, ~12
    7     7        FETCH_DIM_R                                      ~15     !4, 'price'
          8        ASSIGN_DIM                                               !2
          9        OP_DATA                                                  ~15
    8    10        IS_EQUAL                                                 !5, 'mtgmintcard'
         11      > JMPZ                                                     ~16, ->18
    9    12    >   FETCH_DIM_R                                      ~18     !4, 'stock'
         13        ASSIGN_DIM                                               !3, 'stock'
         14        OP_DATA                                                  ~18
   10    15        FETCH_DIM_R                                      ~20     !4, 'price'
         16        ASSIGN_DIM                                               !3, 'price'
         17        OP_DATA                                                  ~20
    6    18    > > JMP                                                      ->5
         19    >   FE_FREE                                                  $11
   13    20        COUNT                                            ~21     !3
         21        IS_IDENTICAL                                             ~21, 0
         22      > JMPZ                                                     ~22, ->24
         23    > > RETURN                                                   <false>
   14    24    >   INIT_FCALL_BY_NAME                                       '_MIN'
         25        SEND_VAR_EX                                              !2
         26        DO_FCALL                                      0  $23     
         27        ASSIGN                                                   !6, $23
   15    28        INIT_FCALL_BY_NAME                                       '_AVG'
         29        SEND_VAR_EX                                              !2
         30        DO_FCALL                                      0  $25     
         31        ASSIGN                                                   !7, $25
   16    32        FETCH_DIM_R                                      ~27     !3, 'stock'
         33        IS_SMALLER_OR_EQUAL                                      1, ~27
         34      > JMPZ                                                     ~28, ->104
   18    35    >   IS_SMALLER_OR_EQUAL                                      !6, 0.1
         36      > JMPNZ                                                    ~30, ->55
   19    37    >   IS_SMALLER                                       ~31     0.1, !6
         38      > JMPZ_EX                                          ~31     ~31, ->41
         39    >   IS_SMALLER                                       ~32     !6, 0.16
         40        BOOL                                             ~31     ~32
         41    > > JMPNZ                                                    ~31, ->61
   20    42    >   IS_SMALLER_OR_EQUAL                              ~33     0.16, !6
         43      > JMPZ_EX                                          ~33     ~33, ->46
         44    >   IS_SMALLER_OR_EQUAL                              ~34     !6, 0.99
         45        BOOL                                             ~33     ~34
         46    > > JMPNZ                                                    ~33, ->68
   21    47    >   IS_SMALLER_OR_EQUAL                              ~35     1, !6
         48      > JMPZ_EX                                          ~35     ~35, ->51
         49    >   IS_SMALLER_OR_EQUAL                              ~36     !6, 1.99
         50        BOOL                                             ~35     ~36
         51    > > JMPNZ                                                    ~35, ->75
   22    52    >   IS_SMALLER_OR_EQUAL                                      2, !6
         53      > JMPNZ                                                    ~37, ->94
         54    > > JMP                                                      ->101
   18    55    > > JMPZ                                                     <false>, ->58
         56    >   QM_ASSIGN                                        ~38     0.05
         57      > JMP                                                      ->59
         58    >   QM_ASSIGN                                        ~38     !6
         59    >   ASSIGN                                                   !8, ~38
         60      > JMP                                                      ->103
   19    61    >   INIT_FCALL_BY_NAME                                       'bcmul'
         62        SEND_VAR_EX                                              !6
         63        SEND_VAL_EX                                              1
         64        SEND_VAL_EX                                              2
         65        DO_FCALL                                      0  $40     
         66        ASSIGN                                                   !8, $40
         67      > JMP                                                      ->103
   20    68    >   INIT_FCALL_BY_NAME                                       'bcmul'
         69        SEND_VAR_EX                                              !7
         70        SEND_VAL_EX                                              0.95
         71        SEND_VAL_EX                                              2
         72        DO_FCALL                                      0  $42     
         73        ASSIGN                                                   !8, $42
         74      > JMP                                                      ->103
   21    75    >   INIT_FCALL_BY_NAME                                       'bcdiv'
         76        INIT_FCALL_BY_NAME                                       'bcmul'
         77        INIT_FCALL_BY_NAME                                       'bcadd'
         78        SEND_VAR_EX                                              !7
         79        CHECK_FUNC_ARG                                           
         80        FETCH_DIM_FUNC_ARG                               $44     !3, 'price'
         81        SEND_FUNC_ARG                                            $44
         82        SEND_VAL_EX                                              2
         83        DO_FCALL                                      0  $45     
         84        SEND_VAR_NO_REF_EX                                       $45
         85        SEND_VAL_EX                                              0.95
         86        SEND_VAL_EX                                              2
         87        DO_FCALL                                      0  $46     
         88        SEND_VAR_NO_REF_EX                                       $46
         89        SEND_VAL_EX                                              2
         90        SEND_VAL_EX                                              2
         91        DO_FCALL                                      0  $47     
         92        ASSIGN                                                   !8, $47
         93      > JMP                                                      ->103
   22    94    >   INIT_FCALL_BY_NAME                                       'bcmul'
         95        SEND_VAR_EX                                              !6
         96        SEND_VAL_EX                                              0.99
         97        SEND_VAL_EX                                              2
         98        DO_FCALL                                      0  $49     
         99        ASSIGN                                                   !8, $49
        100      > JMP                                                      ->103
   23   101    >   ASSIGN                                                   !8, <false>
        102      > JMP                                                      ->103
        103    > > JMP                                                      ->105
   33   104    >   ASSIGN                                                   !8, !7
   35   105    >   FETCH_DIM_R                                      ~53     !3, 'stock'
        106        IS_EQUAL                                                 ~53, -1
        107      > JMPZ                                                     ~54, ->113
        108    >   INIT_FCALL_BY_NAME                                       'FoilPrice'
        109        SEND_VAR_EX                                              !8
        110        DO_FCALL                                      0  $55     
        111        QM_ASSIGN                                        ~56     $55
        112      > JMP                                                      ->114
        113    >   QM_ASSIGN                                        ~56     !8
        114    > > RETURN                                                   ~56
   36   115*     > RETURN                                                   null

End of function price

Function foilprice:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 44) Position 1 = 3, Position 2 = 11
Branch analysis from position: 3
2 jumps found. (Code = 46) Position 1 = 5, Position 2 = 7
Branch analysis from position: 5
2 jumps found. (Code = 44) Position 1 = 8, Position 2 = 18
Branch analysis from position: 8
2 jumps found. (Code = 44) Position 1 = 10, Position 2 = 25
Branch analysis from position: 10
1 jumps found. (Code = 42) Position 1 = 32
Branch analysis from position: 32
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 25
1 jumps found. (Code = 42) Position 1 = 32
Branch analysis from position: 32
Branch analysis from position: 18
1 jumps found. (Code = 42) Position 1 = 32
Branch analysis from position: 32
Branch analysis from position: 7
Branch analysis from position: 11
1 jumps found. (Code = 42) Position 1 = 32
Branch analysis from position: 32
filename:       /in/glGvp
function name:  FoilPrice
number of ops:  34
compiled vars:  !0 = $price
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   37     0  E >   RECV                                             !0      
   39     1        IS_SMALLER_OR_EQUAL                                      !0, 1
          2      > JMPNZ                                                    ~2, ->11
   40     3    >   IS_SMALLER                                       ~3      1, !0
          4      > JMPZ_EX                                          ~3      ~3, ->7
          5    >   IS_SMALLER_OR_EQUAL                              ~4      !0, 10
          6        BOOL                                             ~3      ~4
          7    > > JMPNZ                                                    ~3, ->18
   41     8    >   IS_SMALLER                                               10, !0
          9      > JMPNZ                                                    ~5, ->25
         10    > > JMP                                                      ->32
   39    11    >   INIT_FCALL_BY_NAME                                       'bcmul'
         12        SEND_VAR_EX                                              !0
         13        SEND_VAL_EX                                              2.5
         14        SEND_VAL_EX                                              2
         15        DO_FCALL                                      0  $6      
         16        ASSIGN                                                   !0, $6
         17      > JMP                                                      ->32
   40    18    >   INIT_FCALL_BY_NAME                                       'bcmul'
         19        SEND_VAR_EX                                              !0
         20        SEND_VAL_EX                                              2
         21        SEND_VAL_EX                                              2
         22        DO_FCALL                                      0  $8      
         23        ASSIGN                                                   !0, $8
         24      > JMP                                                      ->32
   41    25    >   INIT_FCALL_BY_NAME                                       'bcmul'
         26        SEND_VAR_EX                                              !0
         27        SEND_VAL_EX                                              1.5
         28        SEND_VAL_EX                                              2
         29        DO_FCALL                                      0  $10     
         30        ASSIGN                                                   !0, $10
         31      > JMP                                                      ->32
   43    32    > > RETURN                                                   !0
   44    33*     > RETURN                                                   null

End of function foilprice

Function _avg:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/glGvp
function name:  _AVG
number of ops:  20
compiled vars:  !0 = $args, !1 = $count, !2 = $sum
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   45     0  E >   RECV                                             !0      
   48     1        COUNT                                            ~3      !0
          2        ASSIGN                                                   !1, ~3
   49     3        INIT_FCALL                                               'array_sum'
          4        SEND_VAR                                                 !0
          5        DO_ICALL                                         $5      
          6        ASSIGN                                                   !2, $5
   50     7        INIT_FCALL_BY_NAME                                       'bcdiv'
          8        SEND_VAR_EX                                              !2
          9        SEND_VAR_EX                                              !1
         10        SEND_VAL_EX                                              2
         11        DO_FCALL                                      0  $7      
         12        ECHO                                                     $7
   51    13        INIT_FCALL_BY_NAME                                       'bcdiv'
         14        SEND_VAR_EX                                              !2
         15        SEND_VAR_EX                                              !1
         16        SEND_VAL_EX                                              2
         17        DO_FCALL                                      0  $8      
         18      > RETURN                                                   $8
   52    19*     > RETURN                                                   null

End of function _avg

Function _min:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/glGvp
function name:  _MIN
number of ops:  10
compiled vars:  !0 = $args
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   53     0  E >   RECV                                             !0      
   54     1        INIT_FCALL                                               'min'
          2        SEND_VAR                                                 !0
          3        DO_ICALL                                         $1      
          4        ECHO                                                     $1
   55     5        INIT_FCALL                                               'min'
          6        SEND_VAR                                                 !0
          7        DO_ICALL                                         $2      
          8      > RETURN                                                   $2
   56     9*     > RETURN                                                   null

End of function _min

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
162.93 ms | 1410 KiB | 18 Q