3v4l.org

run code in 300+ PHP versions simultaneously
<?php function isCorrect($string) { $len = strlen($string); $stack = []; for( $i = 0; i < $len; ++$i) { if ($string[i] == '(') array_push($stack, $string[i]); else if($string[i] == ')') { if ( empty($stack) === false) array_pop($stack); else return false; } } return empty($stack); } $string = '((()))'; 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/OHOPR
function name:  (null)
number of ops:  5
compiled vars:  !0 = $string
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   17     0  E >   ASSIGN                                                   !0, '%28%28%28%29%29%29'
   18     1        INIT_FCALL                                               'iscorrect'
          2        SEND_VAR                                                 !0
          3        DO_FCALL                                      0          
   28     4      > RETURN                                                   1

Function iscorrect:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 30
Branch analysis from position: 30
2 jumps found. (Code = 44) Position 1 = 33, Position 2 = 6
Branch analysis from position: 33
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 6
2 jumps found. (Code = 43) Position 1 = 10, Position 2 = 17
Branch analysis from position: 10
1 jumps found. (Code = 42) Position 1 = 29
Branch analysis from position: 29
2 jumps found. (Code = 44) Position 1 = 33, Position 2 = 6
Branch analysis from position: 33
Branch analysis from position: 6
Branch analysis from position: 17
2 jumps found. (Code = 43) Position 1 = 21, Position 2 = 29
Branch analysis from position: 21
2 jumps found. (Code = 43) Position 1 = 24, Position 2 = 28
Branch analysis from position: 24
1 jumps found. (Code = 42) Position 1 = 29
Branch analysis from position: 29
Branch analysis from position: 28
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 29
filename:       /in/OHOPR
function name:  isCorrect
number of ops:  36
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                                                      ->30
    7     6    >   FETCH_CONSTANT                                   ~8      'i'
          7        FETCH_DIM_R                                      ~9      !0, ~8
          8        IS_EQUAL                                                 ~9, '%28'
          9      > JMPZ                                                     ~10, ->17
         10    >   INIT_FCALL                                               'array_push'
         11        SEND_REF                                                 !2
         12        FETCH_CONSTANT                                   ~11     'i'
         13        FETCH_DIM_R                                      ~12     !0, ~11
         14        SEND_VAL                                                 ~12
         15        DO_ICALL                                                 
         16      > JMP                                                      ->29
    8    17    >   FETCH_CONSTANT                                   ~14     'i'
         18        FETCH_DIM_R                                      ~15     !0, ~14
         19        IS_EQUAL                                                 ~15, '%29'
         20      > JMPZ                                                     ~16, ->29
   10    21    >   ISSET_ISEMPTY_CV                                 ~17     !2
         22        TYPE_CHECK                                    4          ~17
         23      > JMPZ                                                     ~18, ->28
         24    >   INIT_FCALL                                               'array_pop'
         25        SEND_REF                                                 !2
         26        DO_ICALL                                                 
         27      > JMP                                                      ->29
   11    28    > > RETURN                                                   <false>
    5    29    >   PRE_INC                                                  !3
         30    >   FETCH_CONSTANT                                   ~21     'i'
         31        IS_SMALLER                                               ~21, !1
         32      > JMPNZ                                                    ~22, ->6
   15    33    >   ISSET_ISEMPTY_CV                                 ~23     !2
         34      > RETURN                                                   ~23
   16    35*     > RETURN                                                   null

End of function iscorrect

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
167.41 ms | 1394 KiB | 18 Q