See if this suits your needs...
[PHP]<?php
$input = "horse.gallup";
$prefix = strtok($input, ".");
$suffix = strtok(".");
for ($i = strlen($prefix); $i>0; $i--)
{
$new_prefix = make_new_combinations($prefix, $i);
foreach($new_prefix as $key=>$value)
$new_suffix[$key] = $value.".".$suffix;
echo "<pre>";
print_r($new_suffix);
unset($new_suffix);
}
function make_new_combinations($word, $length)
{
$word_array = str_split($word);
$new_words = array();
$flags_array = get_combination_flags(count($word_array), $length);
foreach ($flags_array as $flags)
{
foreach ($flags as $key=>$flag)
if ($flag == 0)
unset($word_array[$key]);
array_push($new_words, implode("", $word_array));
$word_array = str_split($word);
}
return $new_words;
}
function get_combination_flags($total, $required)
{
$flag_array = array();
$bin = "";
for ($i=0; $i<$total; $i++)
$bin .= "1";
$dec = bindec($bin);
for ($i=0; $i<=$dec; $i++)
{
$num_of_chars = count_chars(decbin($i), 1);
if ($num_of_chars[49]==$required)
{
$temp = decbin($i);
$length = strlen($temp);
$pre = "";
if ($length<$total)
for ($j=$length; $j<$total; $j++)
$pre .= "0";
$temp = $pre.$temp;
array_push($flag_array, str_split($temp));
}
}
return $flag_array;
}
?>[/PHP]