Use the [man]file()[/man] function to get the words into an array.
This will grab the words, and create the desired word and md5() hash for it, and put that all into an array for you.
<?php
$wordarray = file('thefile.txt');
$newwordarray = array();
FOREACH($wordarray as $wordnum => $v){
$newwordarray[] = $v." :: ".md5($v);
}
// Next, it implodes the array into a string to output to our file.
$newoutput = implode("\r\n", $newwordarray);
// Now we write our output to the file
$filename = "text.txt";
$handle = fopen($filename, "w+b");
fwrite($handle, $newoutput);
?>
This takes the input and outputs this into a new file:
afterwards :: 622f90ceba19c667b7d2620169144476
apologise :: 1e27a91e5b9ce4e2ad6a718bc59d3d28
behaviour :: 4f5ce9544341a81912731e6c3f39136d
behaviour's :: 35646b63f1931ebc7dfa9d1bf904479f
catalogue :: a6f272c8e389bd8db13c5345a49aad43
Keep in mind, there is absolutely no error checking in this. This is strictly an example for you to figure out how to do what you want to do.