<?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"; }
You have javascript disabled. You will not be able to edit any code.