PHP Classes

PHP Bracket Checker Parser: Parse expressions and return if brackets match

Recommend this page to a friend!
  Info   View files Example   View files View files (3)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog    
Ratings Unique User Downloads Download Rankings
Not yet rated by the usersTotal: 94 All time: 9,844 This week: 107Up
Version License PHP version Categories
bracket-parser 1.0.0Freely Distributable5PHP 5, Validation, Testing, Parsers
Description 

Author

This class can parse expressions and return if brackets match.

It can take a text expression enclosed with brackets and determines if the number and order of open brackets correctly match the closing brackets.

Currently it supports brackets like (, [ and { .

Innovation Award
PHP Programming Innovation award nominee
June 2016
Number 12
Sometimes it is necessary to quickly check if an expression or even a programming code text has the right syntax, opening and closing the right brackets.

This class can implement that kind of quick check by looking if brackets match. It supports either (, [ and { brackets.


Manuel Lemos
Picture of Hakob Hakobyan
  Performance   Level  
Name: Hakob Hakobyan <contact>
Classes: 2 packages by
Country: United States United States
Age: 32
All time rank: 3590474 in United States United States
Week rank: 312 Up38 in United States United States Up
Innovation award
Innovation award
Nominee: 1x

Example

<?php
/**
 * Created by PhpStorm.
 * User: hakob
 * Date: 5/9/16
 * Time: 11:57 AM
 */

$s = "({[]})";
$s1 = "({[]})({{}))";
echo
$s1 .' ';
echo
$s .' ';
include
'BracketParser.php';

if(
BracketParser::parse($s)) {
    echo
"Is OK \n";
}else {
    echo
"Wrong bracket series\n";
}
if(
BracketParser::parse($s1)) {
    echo
"Is OK \n";
}else {
    echo
"Wrong bracket series\n";
}


Details

BracketParser

This Class gets a bracket series as an input and returns true or false if they are correctly configured.


  Files folder image Files  
File Role Description
Plain text file BracketParser.php Class Class source
Accessible without login Plain text file index.php Example Example script
Accessible without login Plain text file README.md Doc. Documentation

 Version Control Unique User Downloads Download Rankings  
 100%
Total:94
This week:0
All time:9,844
This week:107Up