3v4l.org

run code in 300+ PHP versions simultaneously
<?php function parseCondition($cond) { switch ($cond[1]) { case "<": case ">": case "<=": case ">=": $sql = "{$cond[0]}{$cond[1]}{$cond[2]}"; break; default: if (is_array($cond[1])) { $sql = "{$cond[0]} IN(" . implode(',', $cond[1]) . ")"; } else { $sql = "{$cond[0]}={$cond[1]}"; } break; } return $sql; } $conditions = [ ["foo", "bar"], ["foo", "<", "bar"], ["foo", [0, 1, 2, 3]] ]; foreach ($conditions as $condition) { echo htmlentities(parseCondition($condition)) . '<br />'; }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 2, Position 2 = 12
Branch analysis from position: 2
2 jumps found. (Code = 78) Position 1 = 3, Position 2 = 12
Branch analysis from position: 3
1 jumps found. (Code = 42) Position 1 = 2
Branch analysis from position: 2
Branch analysis from position: 12
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 12
filename:       /in/eItuj
function name:  (null)
number of ops:  14
compiled vars:  !0 = $conditions, !1 = $condition
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   23     0  E >   ASSIGN                                                   !0, <array>
   29     1      > FE_RESET_R                                       $3      !0, ->12
          2    > > FE_FETCH_R                                               $3, !1, ->12
   30     3    >   INIT_FCALL                                               'htmlentities'
          4        INIT_FCALL                                               'parsecondition'
          5        SEND_VAR                                                 !1
          6        DO_FCALL                                      0  $4      
          7        SEND_VAR                                                 $4
          8        DO_ICALL                                         $5      
          9        CONCAT                                           ~6      $5, '%3Cbr+%2F%3E'
         10        ECHO                                                     ~6
   29    11      > JMP                                                      ->2
         12    >   FE_FREE                                                  $3
   31    13      > RETURN                                                   1

Function parsecondition:
Finding entry points
Branch analysis from position: 0
6 jumps found. (Code = 188) Position 1 = 12, Position 2 = 12, Position 3 = 12, Position 4 = 12, Position 5 = 20, Position 6 = 3
Branch analysis from position: 12
1 jumps found. (Code = 42) Position 1 = 42
Branch analysis from position: 42
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 12
Branch analysis from position: 12
Branch analysis from position: 12
Branch analysis from position: 20
2 jumps found. (Code = 43) Position 1 = 23, Position 2 = 35
Branch analysis from position: 23
1 jumps found. (Code = 42) Position 1 = 41
Branch analysis from position: 41
1 jumps found. (Code = 42) Position 1 = 42
Branch analysis from position: 42
Branch analysis from position: 35
1 jumps found. (Code = 42) Position 1 = 42
Branch analysis from position: 42
Branch analysis from position: 3
2 jumps found. (Code = 44) Position 1 = 5, Position 2 = 12
Branch analysis from position: 5
2 jumps found. (Code = 44) Position 1 = 7, Position 2 = 12
Branch analysis from position: 7
2 jumps found. (Code = 44) Position 1 = 9, Position 2 = 12
Branch analysis from position: 9
2 jumps found. (Code = 44) Position 1 = 11, Position 2 = 12
Branch analysis from position: 11
1 jumps found. (Code = 42) Position 1 = 20
Branch analysis from position: 20
Branch analysis from position: 12
Branch analysis from position: 12
Branch analysis from position: 12
Branch analysis from position: 12
filename:       /in/eItuj
function name:  parseCondition
number of ops:  45
compiled vars:  !0 = $cond, !1 = $sql
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   RECV                                             !0      
    4     1        FETCH_DIM_R                                      ~2      !0, 1
          2      > SWITCH_STRING                                            ~2, [ '%3C':->12, '%3E':->12, '%3C%3D':->12, '%3E%3D':->12, ], ->20
    5     3    >   CASE                                                     ~2, '%3C'
          4      > JMPNZ                                                    ~3, ->12
    6     5    >   CASE                                                     ~2, '%3E'
          6      > JMPNZ                                                    ~3, ->12
    7     7    >   CASE                                                     ~2, '%3C%3D'
          8      > JMPNZ                                                    ~3, ->12
    8     9    >   CASE                                                     ~2, '%3E%3D'
         10      > JMPNZ                                                    ~3, ->12
         11    > > JMP                                                      ->20
    9    12    >   FETCH_DIM_R                                      ~4      !0, 0
         13        ROPE_INIT                                     3  ~8      ~4
         14        FETCH_DIM_R                                      ~5      !0, 1
         15        ROPE_ADD                                      1  ~8      ~8, ~5
         16        FETCH_DIM_R                                      ~6      !0, 2
         17        ROPE_END                                      2  ~7      ~8, ~6
         18        ASSIGN                                                   !1, ~7
   10    19      > JMP                                                      ->42
   12    20    >   FETCH_DIM_R                                      ~11     !0, 1
         21        TYPE_CHECK                                  128          ~11
         22      > JMPZ                                                     ~12, ->35
   13    23    >   FETCH_DIM_R                                      ~13     !0, 0
         24        NOP                                                      
         25        FAST_CONCAT                                      ~14     ~13, '+IN%28'
         26        INIT_FCALL                                               'implode'
         27        SEND_VAL                                                 '%2C'
         28        FETCH_DIM_R                                      ~15     !0, 1
         29        SEND_VAL                                                 ~15
         30        DO_ICALL                                         $16     
         31        CONCAT                                           ~17     ~14, $16
         32        CONCAT                                           ~18     ~17, '%29'
         33        ASSIGN                                                   !1, ~18
         34      > JMP                                                      ->41
   15    35    >   FETCH_DIM_R                                      ~20     !0, 0
         36        ROPE_INIT                                     3  ~23     ~20
         37        ROPE_ADD                                      1  ~23     ~23, '%3D'
         38        FETCH_DIM_R                                      ~21     !0, 1
         39        ROPE_END                                      2  ~22     ~23, ~21
         40        ASSIGN                                                   !1, ~22
   17    41    > > JMP                                                      ->42
         42    >   FREE                                                     ~2
   20    43      > RETURN                                                   !1
   21    44*     > RETURN                                                   null

End of function parsecondition

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
155.21 ms | 1403 KiB | 18 Q