Simple PHP Algo Checking Parenthesis

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.

How to run

  1. go to working directory and type on bash terminal composer install
  2. run phpunit ./vendor/bin/phpunit --bootstrap vendor/autoload.php SimpleTest.php
  3. See the result

Modify

You can test both input arguments and expected result in SimpleTest.php

Specification

  1. PHP 7.2+
  2. Bash terminal/Powershell/Windows terminal