protected static function replacePlaceholder(&$str, $uniqid, $index)
	{
		$str = preg_replace_callback(
			'(' . preg_quote($uniqid) . '(.))',
			function ($m) use ($index)
			{
				// Replace with $1 where unambiguous and ${1} otherwise
				if (is_numeric($m[1]))
				{
					return '${' . $index . '}' . $m[1];
				}
				else
				{
					return '$' . $index . $m[1];
				}
			},
			$str
		);
	}
protected static function replacePlaceholder(&$str, $uniqid, $index)
	{
		$str = preg_replace_callback(
			'(' . preg_quote($uniqid) . '(.))',
			function ($m) use ($index)
			{
				// Replace with $1 where unambiguous and ${1} otherwise
				if (is_numeric($m[1]))
				{
					return '${' . $index . '}' . $m[1];
				}
				else
				{
					return '$' . $index . $m[1];
				}
			},
			$str
		);
	}
protected static function replacePlaceholder ( & $ str , $ uniqid , $ index ) { $ str = preg_replace_callback ( '(' . preg_quote ( $ uniqid ) . '(.))' , function ( $ m ) use ( $ index ) { // Replace with $1 where unambiguous and ${1} otherwise if ( is_numeric ( $ m [ 1 ] ) ) { return '${' . $ index . '}' . $ m [ 1 ] ; } else { return '$' . $ index . $ m [ 1 ] ; } } , $ str ) ; }
Replace all instances of a uniqid with a PCRE replacement in a string

@param  string  &$str    PCRE replacement
@param  string   $uniqid Unique ID
@param  integer  $index  Capture index
@return void
Replace all instances of a uniqid with a PCRE replacement in a string