3v4l.org

run code in 300+ PHP versions simultaneously
<?php function is_valid($string) { do { $string = str_replace(['()', '{}', '[]'], '', $string, $count); } while ($count); return (int)!$string; } $expressions = array(")(){}", "[]({})", "([])", "{()[]}", "([)]", "{()[]}{()[]}{()[]}{()[]}{()[]}"); foreach ($expressions as $expression) { echo "$expression is " , is_valid($expression) , "\n"; }
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/hYUdn
function name:  (null)
number of ops:  14
compiled vars:  !0 = $expressions, !1 = $expression
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    9     0  E >   ASSIGN                                                   !0, <array>
   10     1      > FE_RESET_R                                       $3      !0, ->12
          2    > > FE_FETCH_R                                               $3, !1, ->12
   11     3    >   NOP                                                      
          4        FAST_CONCAT                                      ~4      !1, '+is+'
          5        ECHO                                                     ~4
          6        INIT_FCALL                                               'is_valid'
          7        SEND_VAR                                                 !1
          8        DO_FCALL                                      0  $5      
          9        ECHO                                                     $5
         10        ECHO                                                     '%0A'
   10    11      > JMP                                                      ->2
         12    >   FE_FREE                                                  $3
   12    13      > RETURN                                                   1

Function is_valid:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 44) Position 1 = 9, Position 2 = 1
Branch analysis from position: 9
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 1
filename:       /in/hYUdn
function name:  is_valid
number of ops:  13
compiled vars:  !0 = $string, !1 = $count
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   RECV                                             !0      
    4     1    >   INIT_FCALL                                               'str_replace'
          2        SEND_VAL                                                 <array>
          3        SEND_VAL                                                 ''
          4        SEND_VAR                                                 !0
          5        SEND_REF                                                 !1
          6        DO_ICALL                                         $2      
          7        ASSIGN                                                   !0, $2
    5     8      > JMPNZ                                                    !1, ->1
    6     9    >   BOOL_NOT                                         ~4      !0
         10        CAST                                          4  ~5      ~4
         11      > RETURN                                                   ~5
    7    12*     > RETURN                                                   null

End of function is_valid

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
138.84 ms | 1003 KiB | 15 Q