<?php function is_valid($string) { return preg_match('~(\((?1)*+\)|\[(?1)*+]|{(?1)*+})*\z~A', $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.