KYKK Posted August 19, 2009 Share Posted August 19, 2009 I mod a game script and I want to check to see if there are the same number of "{" and "}" when I like google code checker i find like HTML CSS.... are there some kind of program just count that {} ? thx Link to comment Share on other sites More sharing options...
Ingolme Posted August 19, 2009 Share Posted August 19, 2009 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 More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.