Jump to content

Code Check


Recommended Posts

You can count the amount of each character easily. But to know if they're properly in order you would have to design a more complex program.In PHP, you can count characters like this:

echo substr_count($str,"{");

Where $str is the string you're checking, of course.If you want to check for brace pairs ( { } ) you'll have to go through each and every character of the string. A recursive function is possible what's needed. Each time you encounter a '{' you go down a level, and each time you encounter a '}' you go back up a level and count one pair.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Create New...