A simple PHP algorithm to get index position end of parenthesis of given string
The function receives "a (b c (d e (f) g) h) i (j k)" and 2 as arguments.
The function should return the index position of the ")" right after "h", in this case, the return value is 20.
- go to working directory and type on bash terminal
composer install
- run phpunit
./vendor/bin/phpunit --bootstrap vendor/autoload.php SimpleTest.php
- See the result
You can test both input arguments and expected result in SimpleTest.php
- PHP 7.2+
- Bash terminal/Powershell/Windows terminal