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 || $mintcard['stock']===-1){ 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,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; } }elseif($mintcard['stock']===0){ //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,3,2); break; case $price > 1.00 && $price <= 10.00: $price = bcmul($price,2.5,2); break; case $price > 10.00: $price = bcmul($price,2,2); break; } return $price; } function _AVG($args){ /*$count = func_num_args(); $args = func_get_args();*/ $count = count($args); $sum = array_sum($args); return bcdiv($sum,$count,2); } function _MIN($args){ return min($args); } $c = array('mtgmintcard' => array('price' => 9.57,'stock' => -1), 'magicmadhouse' => array('price' => 17.09, 'stock' => -1), 'manaleak' => array('price' => 16.99,'stock' => -1) ); echo Price($c,1);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/DbNYL
function name:  (null)
number of ops:  7
compiled vars:  !0 = $c
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   55     0  E >   ASSIGN                                                   !0, <array>
   59     1        INIT_FCALL                                               'price'
          2        SEND_VAR                                                 !0
          3        SEND_VAL                                                 1
          4        DO_FCALL                                      0  $2      
          5        ECHO                                                     $2
          6      > 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 = 47) Position 1 = 37, Position 2 = 40
Branch analysis from position: 37
2 jumps found. (Code = 43) Position 1 = 41, Position 2 = 114
Branch analysis from position: 41
2 jumps found. (Code = 44) Position 1 = 43, Position 2 = 61
Branch analysis from position: 43
2 jumps found. (Code = 46) Position 1 = 45, Position 2 = 47
Branch analysis from position: 45
2 jumps found. (Code = 44) Position 1 = 48, Position 2 = 71
Branch analysis from position: 48
2 jumps found. (Code = 46) Position 1 = 50, Position 2 = 52
Branch analysis from position: 50
2 jumps found. (Code = 44) Position 1 = 53, Position 2 = 78
Branch analysis from position: 53
2 jumps found. (Code = 46) Position 1 = 55, Position 2 = 57
Branch analysis from position: 55
2 jumps found. (Code = 44) Position 1 = 58, Position 2 = 85
Branch analysis from position: 58
2 jumps found. (Code = 44) Position 1 = 60, Position 2 = 104
Branch analysis from position: 60
1 jumps found. (Code = 42) Position 1 = 111
Branch analysis from position: 111
1 jumps found. (Code = 42) Position 1 = 113
Branch analysis from position: 113
1 jumps found. (Code = 42) Position 1 = 118
Branch analysis from position: 118
2 jumps found. (Code = 43) Position 1 = 121, Position 2 = 126
Branch analysis from position: 121
1 jumps found. (Code = 42) Position 1 = 127
Branch analysis from position: 127
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 126
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 104
1 jumps found. (Code = 42) Position 1 = 113
Branch analysis from position: 113
Branch analysis from position: 85
1 jumps found. (Code = 42) Position 1 = 113
Branch analysis from position: 113
Branch analysis from position: 57
Branch analysis from position: 78
1 jumps found. (Code = 42) Position 1 = 113
Branch analysis from position: 113
Branch analysis from position: 52
Branch analysis from position: 71
1 jumps found. (Code = 42) Position 1 = 113
Branch analysis from position: 113
Branch analysis from position: 47
Branch analysis from position: 61
2 jumps found. (Code = 43) Position 1 = 66, Position 2 = 68
Branch analysis from position: 66
1 jumps found. (Code = 42) Position 1 = 69
Branch analysis from position: 69
1 jumps found. (Code = 42) Position 1 = 113
Branch analysis from position: 113
Branch analysis from position: 68
1 jumps found. (Code = 42) Position 1 = 113
Branch analysis from position: 113
Branch analysis from position: 114
2 jumps found. (Code = 43) Position 1 = 117, Position 2 = 118
Branch analysis from position: 117
2 jumps found. (Code = 43) Position 1 = 121, Position 2 = 126
Branch analysis from position: 121
Branch analysis from position: 126
Branch analysis from position: 118
Branch analysis from position: 40
Branch analysis from position: 21
filename:       /in/DbNYL
function name:  Price
number of ops:  129
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                              ~30     1, ~29
         36      > JMPNZ_EX                                         ~30     ~30, ->40
         37    >   FETCH_DIM_R                                      ~31     !3, 'stock'
         38        IS_IDENTICAL                                     ~32     ~31, -1
         39        BOOL                                             ~30     ~32
         40    > > JMPZ                                                     ~30, ->114
   18    41    >   IS_SMALLER_OR_EQUAL                                      !6, 0.1
         42      > JMPNZ                                                    ~34, ->61
   19    43    >   IS_SMALLER                                       ~35     0.1, !6
         44      > JMPZ_EX                                          ~35     ~35, ->47
         45    >   IS_SMALLER                                       ~36     !6, 0.16
         46        BOOL                                             ~35     ~36
         47    > > JMPNZ                                                    ~35, ->71
   20    48    >   IS_SMALLER_OR_EQUAL                              ~37     0.16, !6
         49      > JMPZ_EX                                          ~37     ~37, ->52
         50    >   IS_SMALLER_OR_EQUAL                              ~38     !6, 0.99
         51        BOOL                                             ~37     ~38
         52    > > JMPNZ                                                    ~37, ->78
   21    53    >   IS_SMALLER_OR_EQUAL                              ~39     1, !6
         54      > JMPZ_EX                                          ~39     ~39, ->57
         55    >   IS_SMALLER_OR_EQUAL                              ~40     !6, 1.99
         56        BOOL                                             ~39     ~40
         57    > > JMPNZ                                                    ~39, ->85
   22    58    >   IS_SMALLER_OR_EQUAL                                      2, !6
         59      > JMPNZ                                                    ~41, ->104
         60    > > JMP                                                      ->111
   18    61    >   INIT_FCALL_BY_NAME                                       '_SQL_FETCHSTOCK'
         62        SEND_VAR_EX                                              !1
         63        DO_FCALL                                      0  $42     
         64        IS_SMALLER                                               35, $42
         65      > JMPZ                                                     ~43, ->68
         66    >   QM_ASSIGN                                        ~44     0.05
         67      > JMP                                                      ->69
         68    >   QM_ASSIGN                                        ~44     !6
         69    >   ASSIGN                                                   !8, ~44
         70      > JMP                                                      ->113
   19    71    >   INIT_FCALL_BY_NAME                                       'bcmul'
         72        SEND_VAR_EX                                              !6
         73        SEND_VAL_EX                                              1
         74        SEND_VAL_EX                                              2
         75        DO_FCALL                                      0  $46     
         76        ASSIGN                                                   !8, $46
         77      > JMP                                                      ->113
   20    78    >   INIT_FCALL_BY_NAME                                       'bcmul'
         79        SEND_VAR_EX                                              !7
         80        SEND_VAL_EX                                              0.95
         81        SEND_VAL_EX                                              2
         82        DO_FCALL                                      0  $48     
         83        ASSIGN                                                   !8, $48
         84      > JMP                                                      ->113
   21    85    >   INIT_FCALL_BY_NAME                                       'bcdiv'
         86        INIT_FCALL_BY_NAME                                       'bcmul'
         87        INIT_FCALL_BY_NAME                                       'bcadd'
         88        SEND_VAR_EX                                              !7
         89        CHECK_FUNC_ARG                                           
         90        FETCH_DIM_FUNC_ARG                               $50     !3, 'price'
         91        SEND_FUNC_ARG                                            $50
         92        SEND_VAL_EX                                              2
         93        DO_FCALL                                      0  $51     
         94        SEND_VAR_NO_REF_EX                                       $51
         95        SEND_VAL_EX                                              0.95
         96        SEND_VAL_EX                                              2
         97        DO_FCALL                                      0  $52     
         98        SEND_VAR_NO_REF_EX                                       $52
         99        SEND_VAL_EX                                              2
        100        SEND_VAL_EX                                              2
        101        DO_FCALL                                      0  $53     
        102        ASSIGN                                                   !8, $53
        103      > JMP                                                      ->113
   22   104    >   INIT_FCALL_BY_NAME                                       'bcmul'
        105        SEND_VAR_EX                                              !6
        106        SEND_VAL_EX                                              0.99
        107        SEND_VAL_EX                                              2
        108        DO_FCALL                                      0  $55     
        109        ASSIGN                                                   !8, $55
        110      > JMP                                                      ->113
   23   111    >   ASSIGN                                                   !8, <false>
        112      > JMP                                                      ->113
        113    > > JMP                                                      ->118
   25   114    >   FETCH_DIM_R                                      ~58     !3, 'stock'
        115        IS_IDENTICAL                                             ~58, 0
        116      > JMPZ                                                     ~59, ->118
   33   117    >   ASSIGN                                                   !8, !7
   35   118    >   FETCH_DIM_R                                      ~61     !3, 'stock'
        119        IS_IDENTICAL                                             ~61, -1
        120      > JMPZ                                                     ~62, ->126
        121    >   INIT_FCALL_BY_NAME                                       'FoilPrice'
        122        SEND_VAR_EX                                              !8
        123        DO_FCALL                                      0  $63     
        124        QM_ASSIGN                                        ~64     $63
        125      > JMP                                                      ->127
        126    >   QM_ASSIGN                                        ~64     !8
        127    > > RETURN                                                   ~64
   36   128*     > 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/DbNYL
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                                              3
         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.5
         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                                              2
         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/DbNYL
function name:  _AVG
number of ops:  14
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      > RETURN                                                   $7
   51    13*     > 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/DbNYL
function name:  _MIN
number of ops:  6
compiled vars:  !0 = $args
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   52     0  E >   RECV                                             !0      
   53     1        INIT_FCALL                                               'min'
          2        SEND_VAR                                                 !0
          3        DO_ICALL                                         $1      
          4      > RETURN                                                   $1
   54     5*     > RETURN                                                   null

End of function _min

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
165.19 ms | 1419 KiB | 27 Q