View Single Post
Old 12-03-2008, 09:49 PM   #2 (permalink)
liveordie
The Visitor
 
Join Date: Nov 2008
Posts: 3
Thanks: 0
liveordie is on a distinguished road
Default

PHP Code:
<?php

//Read the file line by line into an array
$lines file'/path/to/file.txt' );

//Loop over the array by line
foreach( $lines as $line )
{
    
$parts = array();

    
//Explode each line into exactly 3 parts by a space.
    //Allows the definition to have multiple words separated by spaces.
    
$parts explode' '$line);

    
//Print out the three resulting parts
    
echo 'Word: ' $parts[0] . '<br />';
    echo 
'Type: ' $parts[1] . '<br />';
    echo 
'Definition: ' $parts[2] . '<br />';
}
If the second part is an abbreviation like n. v. adj. or something of that sort, you can strip the period of the second part that is returned from the explode function
liveordie is offline  
Reply With Quote