3v4l.org

run code in 300+ PHP versions simultaneously
<?php function isCorrect($string) { $wait = array(); for ($i = 0; $i < strlen($string); $i++) { if ($string[$i] == '{') { array_push($wait, '}'); } elseif ($string[$i] == '(') { array_push($wait, ')'); } elseif ($string[$i] == '}' && end($wait) == '}') { array_pop($wait); } elseif ($string[$i] == ')' && end($wait) == ')') { array_pop($wait); } elseif ($string[$i] == ')' || $string[$i] == '}') { return false; } } return empty($wait); } 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/KoRZR
function name:  (null)
number of ops:  64
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   19     0  E >   ASSERT_CHECK                                             
          1        INIT_FCALL                                               'assert'
          2        INIT_FCALL                                               'iscorrect'
          3        SEND_VAL                                                 ''
          4        DO_FCALL                                      0  $0      
          5        TYPE_CHECK                                    8  ~1      $0
          6        SEND_VAL                                                 ~1
          7        SEND_VAL                                                 'assert%28isCorrect%28%27%27%29+%3D%3D%3D+true%29'
          8        DO_ICALL                                                 
   20     9        ASSERT_CHECK                                             
         10        INIT_FCALL                                               'assert'
         11        INIT_FCALL                                               'iscorrect'
         12        SEND_VAL                                                 '%28%29'
         13        DO_FCALL                                      0  $3      
         14        TYPE_CHECK                                    8  ~4      $3
         15        SEND_VAL                                                 ~4
         16        SEND_VAL                                                 'assert%28isCorrect%28%27%28%29%27%29+%3D%3D%3D+true%29'
         17        DO_ICALL                                                 
   21    18        ASSERT_CHECK                                             
         19        INIT_FCALL                                               'assert'
         20        INIT_FCALL                                               'iscorrect'
         21        SEND_VAL                                                 '%7B%28%29%7D'
         22        DO_FCALL                                      0  $6      
         23        TYPE_CHECK                                    8  ~7      $6
         24        SEND_VAL                                                 ~7
         25        SEND_VAL                                                 'assert%28isCorrect%28%27%7B%28%29%7D%27%29+%3D%3D%3D+true%29'
         26        DO_ICALL                                                 
   22    27        ASSERT_CHECK                                             
         28        INIT_FCALL                                               'assert'
         29        INIT_FCALL                                               'iscorrect'
         30        SEND_VAL                                                 '%7B%28%29%7D%7B%7D'
         31        DO_FCALL                                      0  $9      
         32        TYPE_CHECK                                    8  ~10     $9
         33        SEND_VAL                                                 ~10
         34        SEND_VAL                                                 'assert%28isCorrect%28%27%7B%28%29%7D%7B%7D%27%29+%3D%3D%3D+true%29'
         35        DO_ICALL                                                 
   23    36        ASSERT_CHECK                                             
         37        INIT_FCALL                                               'assert'
         38        INIT_FCALL                                               'iscorrect'
         39        SEND_VAL                                                 '%28%28%29%29'
         40        DO_FCALL                                      0  $12     
         41        TYPE_CHECK                                    8  ~13     $12
         42        SEND_VAL                                                 ~13
         43        SEND_VAL                                                 'assert%28isCorrect%28%27%28%28%29%29%27%29+%3D%3D%3D+true%29'
         44        DO_ICALL                                                 
   24    45        ASSERT_CHECK                                             
         46        INIT_FCALL                                               'assert'
         47        INIT_FCALL                                               'iscorrect'
         48        SEND_VAL                                                 '%7B%28%7B%28%7B%28%7B%28%29%7D%29%7D%29%7D%29%7D'
         49        DO_FCALL                                      0  $15     
         50        TYPE_CHECK                                    8  ~16     $15
         51        SEND_VAL                                                 ~16
         52        SEND_VAL                                                 'assert%28isCorrect%28%27%7B%28%7B%28%7B%28%7B%28%29%7D%29%7D%29%7D%29%7D%27%29+%3D%3D%3D+true%29'
         53        DO_ICALL                                                 
   25    54        ASSERT_CHECK                                             
         55        INIT_FCALL                                               'assert'
         56        INIT_FCALL                                               'iscorrect'
         57        SEND_VAL                                                 '%7B%28%7D%29'
         58        DO_FCALL                                      0  $18     
         59        TYPE_CHECK                                    4  ~19     $18
         60        SEND_VAL                                                 ~19
         61        SEND_VAL                                                 'assert%28isCorrect%28%27%7B%28%7D%29%27%29+%3D%3D%3D+false%29'
         62        DO_ICALL                                                 
         63      > RETURN                                                   1

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

End of function iscorrect

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
166.99 ms | 1411 KiB | 28 Q