3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?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); } assert(isCorrect('') === true); assert(isCorrect('()') === true); assert(isCorrect('{()}') === true); assert(isCorrect('{()}{}') === true); assert(isCorrect('(())') === true); assert(isCorrect('{({({({()})})})}') === true); assert(isCorrect('{(})') === false);
based on e9SVQ
Output for 7.0.0 - 7.1.0
Warning: assert(): assert(isCorrect('{(})') === false) failed in /in/ZOU55 on line 24
Output for 4.3.2 - 5.6.28
Warning: assert(): Assertion failed in /in/ZOU55 on line 24
Output for 4.3.0 - 4.3.1
Warning: assert() [http://www.php.net/function.assert]: Assertion failed in /in/ZOU55 on line 24