3v4l.org

run code in 300+ PHP versions simultaneously
<?php function isCorrect($string) { $len = strlen($string); $stack = array(); for( $i = 0; $i < $len; ++$i) { if ( $string[$i] == '(' || $string[$i] == '{' || $string[$i] == '[') array_push($stack, $string[$i]); elseif( $string[$i] == ')' || $string[$i] == '}' || $string[$i] == ']') { if ( empty($stack) === false ) array_pop($stack); else return false; } } return empty($stack); } $string = '()[]((({{{}}})))'; var_dump(isCorrect($string)); //var_dump(isCorrect($string)); //var_dump(strlen($string) % 2); //assert(isCorrect('') === true); //assert(isCorrect('()') === true); //assert(isCorrect('{()}') === true); //assert(isCorrect('{()}{}') === true); //assert(isCorrect('(())') === true); //assert(isCorrect('{({({({()})})})}') === true); //assert(isCorrect('{(})') === false);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/TD9dU
function name:  (null)
number of ops:  8
compiled vars:  !0 = $string
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   17     0  E >   ASSIGN                                                   !0, '%28%29%5B%5D%28%28%28%7B%7B%7B%7D%7D%7D%29%29%29'
   18     1        INIT_FCALL                                               'var_dump'
          2        INIT_FCALL                                               'iscorrect'
          3        SEND_VAR                                                 !0
          4        DO_FCALL                                      0  $2      
          5        SEND_VAR                                                 $2
          6        DO_ICALL                                                 
   28     7      > RETURN                                                   1

Function iscorrect:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 43
Branch analysis from position: 43
2 jumps found. (Code = 44) Position 1 = 45, Position 2 = 6
Branch analysis from position: 45
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 6
2 jumps found. (Code = 47) Position 1 = 9, Position 2 = 12
Branch analysis from position: 9
2 jumps found. (Code = 47) Position 1 = 13, Position 2 = 16
Branch analysis from position: 13
2 jumps found. (Code = 43) Position 1 = 17, Position 2 = 23
Branch analysis from position: 17
1 jumps found. (Code = 42) Position 1 = 42
Branch analysis from position: 42
2 jumps found. (Code = 44) Position 1 = 45, Position 2 = 6
Branch analysis from position: 45
Branch analysis from position: 6
Branch analysis from position: 23
2 jumps found. (Code = 47) Position 1 = 26, Position 2 = 29
Branch analysis from position: 26
2 jumps found. (Code = 47) Position 1 = 30, Position 2 = 33
Branch analysis from position: 30
2 jumps found. (Code = 43) Position 1 = 34, Position 2 = 42
Branch analysis from position: 34
2 jumps found. (Code = 43) Position 1 = 37, Position 2 = 41
Branch analysis from position: 37
1 jumps found. (Code = 42) Position 1 = 42
Branch analysis from position: 42
Branch analysis from position: 41
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 42
Branch analysis from position: 33
Branch analysis from position: 29
Branch analysis from position: 16
Branch analysis from position: 12
filename:       /in/TD9dU
function name:  isCorrect
number of ops:  48
compiled vars:  !0 = $string, !1 = $len, !2 = $stack, !3 = $i
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   RECV                                             !0      
    3     1        STRLEN                                           ~4      !0
          2        ASSIGN                                                   !1, ~4
    4     3        ASSIGN                                                   !2, <array>
    5     4        ASSIGN                                                   !3, 0
          5      > JMP                                                      ->43
    7     6    >   FETCH_DIM_R                                      ~8      !0, !3
          7        IS_EQUAL                                         ~9      ~8, '%28'
          8      > JMPNZ_EX                                         ~9      ~9, ->12
          9    >   FETCH_DIM_R                                      ~10     !0, !3
         10        IS_EQUAL                                         ~11     ~10, '%7B'
         11        BOOL                                             ~9      ~11
         12    > > JMPNZ_EX                                         ~9      ~9, ->16
         13    >   FETCH_DIM_R                                      ~12     !0, !3
         14        IS_EQUAL                                         ~13     ~12, '%5B'
         15        BOOL                                             ~9      ~13
         16    > > JMPZ                                                     ~9, ->23
         17    >   INIT_FCALL                                               'array_push'
         18        SEND_REF                                                 !2
         19        FETCH_DIM_R                                      ~14     !0, !3
         20        SEND_VAL                                                 ~14
         21        DO_ICALL                                                 
         22      > JMP                                                      ->42
    8    23    >   FETCH_DIM_R                                      ~16     !0, !3
         24        IS_EQUAL                                         ~17     ~16, '%29'
         25      > JMPNZ_EX                                         ~17     ~17, ->29
         26    >   FETCH_DIM_R                                      ~18     !0, !3
         27        IS_EQUAL                                         ~19     ~18, '%7D'
         28        BOOL                                             ~17     ~19
         29    > > JMPNZ_EX                                         ~17     ~17, ->33
         30    >   FETCH_DIM_R                                      ~20     !0, !3
         31        IS_EQUAL                                         ~21     ~20, '%5D'
         32        BOOL                                             ~17     ~21
         33    > > JMPZ                                                     ~17, ->42
   10    34    >   ISSET_ISEMPTY_CV                                 ~22     !2
         35        TYPE_CHECK                                    4          ~22
         36      > JMPZ                                                     ~23, ->41
         37    >   INIT_FCALL                                               'array_pop'
         38        SEND_REF                                                 !2
         39        DO_ICALL                                                 
         40      > JMP                                                      ->42
   11    41    > > RETURN                                                   <false>
    5    42    >   PRE_INC                                                  !3
         43    >   IS_SMALLER                                               !3, !1
         44      > JMPNZ                                                    ~26, ->6
   15    45    >   ISSET_ISEMPTY_CV                                 ~27     !2
         46      > RETURN                                                   ~27
   16    47*     > RETURN                                                   null

End of function iscorrect

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
164.11 ms | 1403 KiB | 20 Q