Created
January 23, 2017 01:21
-
-
Save jsiesquen/0241f515708574cc3f51e9cbd3052890 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Class for extract chars paring | |
* Support: | |
* On PHP 5.x | |
* Execution using: | |
* - From Code Inside, instance from Class: | |
* $cp = new ClearPar(); | |
* echo $cp->build('(()()()()(()))))())((())'); | |
*/ | |
class ClearPar | |
{ | |
var $outputString = ''; | |
function __construct() | |
{ | |
} | |
/** | |
* Extract chars paring | |
*/ | |
function build($inputString = null) | |
{ | |
preg_match_all('/\(\)/', $inputString, $matching, PREG_OFFSET_CAPTURE); | |
if (count($matching[0]) > 0) | |
{ | |
foreach ($matching[0] as $k => $v) | |
$this->outputString .= substr($inputString, $v[1], 2); | |
} | |
return "Input String:\n" . $inputString . "\n\n\n" . | |
"Result:\n" . $this->outputString; | |
} | |
} | |
$cp = new ClearPar(); | |
echo $cp->build('aognn *236 (()()()()(()))))())((()) asj'); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment