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