<?php
	$subject="maxmuster";
	$str="max";
	
	$comb=str_split($subject); // Split into single characters.
	$len=strlen($subject);
	
	for ($i=2; $i<=$len; $i++){
		for($start=0; $start<$len; $start++){
			$temp="";
			$inc=$start;
			for($j=0; $j<$i; $j++){
				$temp=$temp.$subject[$inc];
				$inc++;
			}
			array_push($comb,$temp);
		}
	}
	
	//print_r($comb);
	echo "Matches are:\n";
	for($i=0; $i<sizeof($comb); $i++){
		$pattern = "/".$comb[$i]."/";
		if(preg_match($pattern,$str, $matches)){
			print_r($matches);	
		};
	}
?>