PHP code example of igorsa / bracket-check

1. Go to this page and download the library: Download igorsa/bracket-check library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

igorsa / bracket-check example snippets


use App\IsBalanced;

$bracketsChecker = new IsBalanced('(){}[]'); // String '(){}[]' brackets for checked

// tests

echo $bracketsChecker->isCorrect('(())'); // true
echo $bracketsChecker->isCorrect('((())'); // false
echo $bracketsChecker->isCorrect('()'); // true
echo $bracketsChecker->isCorrect('(('); // false
echo $bracketsChecker->isCorrect('())('); // false
echo $bracketsChecker->isCorrect('((())'); // false
echo $bracketsChecker->isCorrect('(())())'); //false
echo $bracketsChecker->isCorrect('(()(()))))'); // false
echo $bracketsChecker->isCorrect(')'); // false
echo $bracketsChecker->isCorrect('())(()'); // false
echo $bracketsChecker->isCorrect('(){)}((})'); // false
echo $bracketsChecker->isCorrect('(()(()))((()))'); // true
echo $bracketsChecker->isCorrect('(({})(([])))((({[]})))'); // true