PHP Classes

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

Recommend this page to a friend!
     
  Info   Example   View files Files   Install with Composer Install with Composer   Download Download   Reputation   Support forum   Blog    
Ratings Unique User Downloads Download Rankings
Not yet rated by the usersTotal: 95 All time: 9,867 This week: 206Up
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: 33
All time rank: 3599474 in United States United States
Week rank: 181 Up16 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 (3)  
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

The PHP Classes site has supported package installation using the Composer tool since 2013, as you may verify by reading this instructions page.
Install with Composer Install with Composer
 Version Control Unique User Downloads Download Rankings  
 100%
Total:95
This week:0
All time:9,867
This week:206Up