3v4l.org

run code in 500+ PHP versions simultaneously
<?php function tableName () { return 'table_name'; } function select (array $columns, array $where) { for ($i = 0; $i < count($where); $i++){ $conditions[] = $where[$i][0] . ' ' . $where[$i][1] . ' :' . $where[$i][0]; $params[] = $where[$i][2]; } $sql = implode(" AND ", array_map(fn($cond) => "$cond", $conditions)); $columns = implode(", ",array_map(fn($att) => "$att",$columns)); echo "SELECT $columns FROM ".tableName()." WHERE $sql"; } $arrayCol = ["username","email"]; $arrayWhere = [["id", ">", 3], ["firstname", "=", "John"]]; select($arrayCol,$arrayWhere); ?>
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/aEsZi
function name:  (null)
number of ops:  7
compiled vars:  !0 = $arrayCol, !1 = $arrayWhere
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   15     0  E >   ASSIGN                                                       !0, <array>
   16     1        ASSIGN                                                       !1, <array>
   17     2        INIT_FCALL                                                   'select'
          3        SEND_VAR                                                     !0
          4        SEND_VAR                                                     !1
          5        DO_FCALL                                          0          
   19     6      > RETURN                                                       1

Function tablename:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/aEsZi
function name:  tableName
number of ops:  2
compiled vars:  none
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    3     0  E > > RETURN                                                       'table_name'
    4     1*     > RETURN                                                       null

End of function tablename

Function select:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 21
Branch analysis from position: 21
2 jumps found. (Code = 44) Position 1 = 24, Position 2 = 4
Branch analysis from position: 24
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 4
2 jumps found. (Code = 44) Position 1 = 24, Position 2 = 4
Branch analysis from position: 24
Branch analysis from position: 4
filename:       /in/aEsZi
function name:  select
number of ops:  49
compiled vars:  !0 = $columns, !1 = $where, !2 = $i, !3 = $conditions, !4 = $params, !5 = $sql
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    6     0  E >   RECV                                                 !0      
          1        RECV                                                 !1      
    7     2        ASSIGN                                                       !2, 0
          3      > JMP                                                          ->21
    8     4    >   FETCH_DIM_R                                          ~8      !1, !2
          5        FETCH_DIM_R                                          ~9      ~8, 0
          6        CONCAT                                               ~10     ~9, '+'
          7        FETCH_DIM_R                                          ~11     !1, !2
          8        FETCH_DIM_R                                          ~12     ~11, 1
          9        CONCAT                                               ~13     ~10, ~12
         10        CONCAT                                               ~14     ~13, '+%3A'
         11        FETCH_DIM_R                                          ~15     !1, !2
         12        FETCH_DIM_R                                          ~16     ~15, 0
         13        CONCAT                                               ~17     ~14, ~16
         14        ASSIGN_DIM                                                   !3
         15        OP_DATA                                                      ~17
    9    16        FETCH_DIM_R                                          ~19     !1, !2
         17        FETCH_DIM_R                                          ~20     ~19, 2
         18        ASSIGN_DIM                                                   !4
         19        OP_DATA                                                      ~20
    7    20        PRE_INC                                                      !2
         21    >   COUNT                                                ~22     !1
         22        IS_SMALLER                                                   !2, ~22
         23      > JMPNZ                                                        ~23, ->4
   11    24    >   INIT_FCALL                                                   'array_map'
         25        DECLARE_LAMBDA_FUNCTION                              ~24     [0]
         26        SEND_VAL                                                     ~24
         27        SEND_VAR                                                     !3
         28        DO_ICALL                                             $25     
         29        FRAMELESS_ICALL_2                implode             ~26     '+AND+', $25
         30        ASSIGN                                                       !5, ~26
   12    31        INIT_FCALL                                                   'array_map'
         32        DECLARE_LAMBDA_FUNCTION                              ~28     [1]
         33        SEND_VAL                                                     ~28
         34        SEND_VAR                                                     !0
         35        DO_ICALL                                             $29     
         36        FRAMELESS_ICALL_2                implode             ~30     '%2C+', $29
         37        ASSIGN                                                       !0, ~30
   13    38        ROPE_INIT                                         3  ~33     'SELECT+'
         39        ROPE_ADD                                          1  ~33     ~33, !0
         40        ROPE_END                                          2  ~32     ~33, '+FROM+'
         41        INIT_FCALL                                                   'tablename'
         42        DO_FCALL                                          0  $35     
         43        CONCAT                                               ~36     ~32, $35
         44        NOP                                                          
         45        FAST_CONCAT                                          ~37     '+WHERE+', !5
         46        CONCAT                                               ~38     ~36, ~37
         47        ECHO                                                         ~38
   14    48      > RETURN                                                       null


Dynamic Functions:
Dynamic Function 0
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/aEsZi
function name:  {closure:select():11}
number of ops:  4
compiled vars:  !0 = $cond
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   11     0  E >   RECV                                                 !0      
          1        CAST                                              6  ~1      !0
          2      > RETURN                                                       ~1
          3*     > RETURN                                                       null

End of Dynamic Function 0

Dynamic Function 1
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/aEsZi
function name:  {closure:select():12}
number of ops:  4
compiled vars:  !0 = $att
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   12     0  E >   RECV                                                 !0      
          1        CAST                                              6  ~1      !0
          2      > RETURN                                                       ~1
          3*     > RETURN                                                       null

End of Dynamic Function 1

End of function select

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
166.89 ms | 1904 KiB | 16 Q