Skip to content

Instantly share code, notes, and snippets.

@jsiesquen
Created January 23, 2017 01:21
Show Gist options
  • Save jsiesquen/0241f515708574cc3f51e9cbd3052890 to your computer and use it in GitHub Desktop.
Save jsiesquen/0241f515708574cc3f51e9cbd3052890 to your computer and use it in GitHub Desktop.
<?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