static function matchAll($pattern, $buffer, $vars, &$matches)
	{
		$tmp = array();
		if ( preg_match_all($pattern, $buffer, $tmp, PREG_SET_ORDER) === FALSE )
			return false;
		else
		{
			// for all matching substrings
			for ( $m = 0 ; $m < count($tmp) ; $m++ )
			{
				$res = array();
				
				// for all named capturing parenthesis 
				for ( $v = 0 ; $v < count($vars) ; $v++ )
					// if this capture group must be returned (name not empty)
					if ( $vars[$v] != '' )
						$res[$vars[$v]] = $tmp[$m][1+$v];		//$matches[0] = full matching string, first matching parenthesis is at column 1
					
				// new matching substring to return
				$matches[] = $res;
			}
			
		
			return true;
		}
	}
static function matchAll($pattern, $buffer, $vars, &$matches)
	{
		$tmp = array();
		if ( preg_match_all($pattern, $buffer, $tmp, PREG_SET_ORDER) === FALSE )
			return false;
		else
		{
			// for all matching substrings
			for ( $m = 0 ; $m < count($tmp) ; $m++ )
			{
				$res = array();
				
				// for all named capturing parenthesis 
				for ( $v = 0 ; $v < count($vars) ; $v++ )
					// if this capture group must be returned (name not empty)
					if ( $vars[$v] != '' )
						$res[$vars[$v]] = $tmp[$m][1+$v];		//$matches[0] = full matching string, first matching parenthesis is at column 1
					
				// new matching substring to return
				$matches[] = $res;
			}
			
		
			return true;
		}
	}
static function matchAll ( $ pattern , $ buffer , $ vars , & $ matches ) { $ tmp = array ( ) ; if ( preg_match_all ( $ pattern , $ buffer , $ tmp , PREG_SET_ORDER ) === FALSE ) return false ; else { // for all matching substrings for ( $ m = 0 ; $ m < count ( $ tmp ) ; $ m ++ ) { $ res = array ( ) ; // for all named capturing parenthesis  for ( $ v = 0 ; $ v < count ( $ vars ) ; $ v ++ ) // if this capture group must be returned (name not empty) if ( $ vars [ $ v ] != '' ) $ res [ $ vars [ $ v ] ] = $ tmp [ $ m ] [ 1 + $ v ] ; //$matches[0] = full matching string, first matching parenthesis is at column 1 // new matching substring to return $ matches [ ] = $ res ; } return true ; } }
Convenient function to extract data from a string through a regular expression.

We get data in an associative array (instead of numeric indexes for capturing parenthesis).
The function set all matching substrings (preg_match_all) in the matches paremeters (passed by reference), so the
returned array is in fact an array of array : first index is the n-substring matching, second index is the named parenthesis data.

@param string $pattern PCRE regular expression
@param string $buffer String to be searched
@param string[] $vars Array of strings, naming capturing parenthesis in their order of appearance in the pattern
@param string[] $matches Array of matches (passed by reference)
@return bool Return true of false (no match)
Convenient function to extract data from a string through a regular expression .