Try this
Code:
// Text file containing words 
$txt = '/path/to/wordfile.txt'; 

$handle = fopen($txt, 'r'); 

if (!$handle) { 
   die('Could not open...'); 
} 

// set up arrays for storing words and concatenated words 
$words = array(); 
$cwords = array(); 

// get the words
while (!feof($handle)) {
   // strip_newlines is not a real function - needs to be implemented
   array_push($words, trim(fgets($handle)));
}


// while we still have words 
for ($i = 0; $i < count($words); $i++) { 
   // get the current word 
   $curword = $words[$i]; 
   // loop over the words 
   foreach ($words as $word) { 
      // if the word is the same as the current word, skip it - i.e. no CatCat 
      if ($word == $curword) { 
         continue; 
      } 
      // append the concatenated word to the array 
      array_push($cwords, $curword.$word); 
    } 
} 

print_r($words); 
print_r($cwords);