3v4l.org

run code in 300+ PHP versions simultaneously
<?php $condition = array( 'AND', array( array( 'field' => 'grid_enable', 'compare' => '==', 'value' => 1 ), ), array( array( 'field' => 'grid_column', 'compare' => '>=', 'value' => 3 ), ), array( 'OR', array( 'field' => 'filter', 'compare' => '!=', 'value' => 1 ), array( 'field' => 'align', 'compare' => '==', 'value' => 'left' ) ), array( array( 'field' => 'grid_gutter', 'compare' => '==', 'value' => 'large' ), ), ); print_r($condition); $final_result = ''; $double = false; foreach($condition as $k=>$v){ $result = []; if(!is_array($v)){ $operator_out = $v; }else{ foreach($v as $k1=>$v1){ if(!is_array($v1)){ $operator_inn = $v1; }else{ $result[] = implode(' ',array_values($v1)); } } } if(count($result) == 1){ if($double){ $final_result.= " ".$operator_out." ".$result[0]; }else{ $final_result.= $result[0]." ".$operator_out." "; } } else if(count($result) == 2){ $final_result.= "(".implode(" $operator_inn " , $result).")"; $double= true; } } echo $final_result; ?>
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 7, Position 2 = 65
Branch analysis from position: 7
2 jumps found. (Code = 78) Position 1 = 8, Position 2 = 65
Branch analysis from position: 8
2 jumps found. (Code = 43) Position 1 = 13, Position 2 = 15
Branch analysis from position: 13
1 jumps found. (Code = 42) Position 1 = 34
Branch analysis from position: 34
2 jumps found. (Code = 43) Position 1 = 37, Position 2 = 50
Branch analysis from position: 37
2 jumps found. (Code = 43) Position 1 = 38, Position 2 = 44
Branch analysis from position: 38
1 jumps found. (Code = 42) Position 1 = 49
Branch analysis from position: 49
1 jumps found. (Code = 42) Position 1 = 64
Branch analysis from position: 64
1 jumps found. (Code = 42) Position 1 = 7
Branch analysis from position: 7
Branch analysis from position: 44
1 jumps found. (Code = 42) Position 1 = 64
Branch analysis from position: 64
Branch analysis from position: 50
2 jumps found. (Code = 43) Position 1 = 53, Position 2 = 64
Branch analysis from position: 53
1 jumps found. (Code = 42) Position 1 = 7
Branch analysis from position: 7
Branch analysis from position: 64
Branch analysis from position: 15
2 jumps found. (Code = 77) Position 1 = 16, Position 2 = 33
Branch analysis from position: 16
2 jumps found. (Code = 78) Position 1 = 17, Position 2 = 33
Branch analysis from position: 17
2 jumps found. (Code = 43) Position 1 = 21, Position 2 = 23
Branch analysis from position: 21
1 jumps found. (Code = 42) Position 1 = 32
Branch analysis from position: 32
1 jumps found. (Code = 42) Position 1 = 16
Branch analysis from position: 16
Branch analysis from position: 23
1 jumps found. (Code = 42) Position 1 = 16
Branch analysis from position: 16
Branch analysis from position: 33
2 jumps found. (Code = 43) Position 1 = 37, Position 2 = 50
Branch analysis from position: 37
Branch analysis from position: 50
Branch analysis from position: 33
Branch analysis from position: 65
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 65
filename:       /in/BWmus
function name:  (null)
number of ops:  68
compiled vars:  !0 = $condition, !1 = $final_result, !2 = $double, !3 = $v, !4 = $k, !5 = $result, !6 = $operator_out, !7 = $v1, !8 = $k1, !9 = $operator_inn
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                   !0, <array>
   40     1        INIT_FCALL                                               'print_r'
          2        SEND_VAR                                                 !0
          3        DO_ICALL                                                 
   41     4        ASSIGN                                                   !1, ''
   42     5        ASSIGN                                                   !2, <false>
   43     6      > FE_RESET_R                                       $14     !0, ->65
          7    > > FE_FETCH_R                                       ~15     $14, !3, ->65
          8    >   ASSIGN                                                   !4, ~15
   44     9        ASSIGN                                                   !5, <array>
   45    10        TYPE_CHECK                                  128  ~18     !3
         11        BOOL_NOT                                         ~19     ~18
         12      > JMPZ                                                     ~19, ->15
   46    13    >   ASSIGN                                                   !6, !3
   45    14      > JMP                                                      ->34
   48    15    > > FE_RESET_R                                       $21     !3, ->33
         16    > > FE_FETCH_R                                       ~22     $21, !7, ->33
         17    >   ASSIGN                                                   !8, ~22
   49    18        TYPE_CHECK                                  128  ~24     !7
         19        BOOL_NOT                                         ~25     ~24
         20      > JMPZ                                                     ~25, ->23
   50    21    >   ASSIGN                                                   !9, !7
   49    22      > JMP                                                      ->32
   52    23    >   INIT_FCALL                                               'implode'
         24        SEND_VAL                                                 '+'
         25        INIT_FCALL                                               'array_values'
         26        SEND_VAR                                                 !7
         27        DO_ICALL                                         $28     
         28        SEND_VAR                                                 $28
         29        DO_ICALL                                         $29     
         30        ASSIGN_DIM                                               !5
         31        OP_DATA                                                  $29
   48    32    > > JMP                                                      ->16
         33    >   FE_FREE                                                  $21
   57    34    >   COUNT                                            ~30     !5
         35        IS_EQUAL                                                 ~30, 1
         36      > JMPZ                                                     ~31, ->50
   58    37    > > JMPZ                                                     !2, ->44
   59    38    >   CONCAT                                           ~32     '+', !6
         39        CONCAT                                           ~33     ~32, '+'
         40        FETCH_DIM_R                                      ~34     !5, 0
         41        CONCAT                                           ~35     ~33, ~34
         42        ASSIGN_OP                                     8          !1, ~35
   58    43      > JMP                                                      ->49
   61    44    >   FETCH_DIM_R                                      ~37     !5, 0
         45        CONCAT                                           ~38     ~37, '+'
         46        CONCAT                                           ~39     ~38, !6
         47        CONCAT                                           ~40     ~39, '+'
         48        ASSIGN_OP                                     8          !1, ~40
   57    49    > > JMP                                                      ->64
   65    50    >   COUNT                                            ~42     !5
         51        IS_EQUAL                                                 ~42, 2
         52      > JMPZ                                                     ~43, ->64
   66    53    >   INIT_FCALL                                               'implode'
         54        ROPE_INIT                                     3  ~45     '+'
         55        ROPE_ADD                                      1  ~45     ~45, !9
         56        ROPE_END                                      2  ~44     ~45, '+'
         57        SEND_VAL                                                 ~44
         58        SEND_VAR                                                 !5
         59        DO_ICALL                                         $47     
         60        CONCAT                                           ~48     '%28', $47
         61        CONCAT                                           ~49     ~48, '%29'
         62        ASSIGN_OP                                     8          !1, ~49
   67    63        ASSIGN                                                   !2, <true>
   43    64    > > JMP                                                      ->7
         65    >   FE_FREE                                                  $14
   70    66        ECHO                                                     !1
   71    67      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
217.63 ms | 1077 KiB | 16 Q