View Single Post
Old 05-03-2009, 10:32 PM  
ProG
Confirmed User
 
Join Date: Apr 2009
Posts: 1,319
One more revision that will give you a listing of unique words (no duplicates).

PHP Code:
<?php
$unique_words 
= array( );
if ( ( 
$file file"file.txt" ) ) !== false )
{
    foreach( 
$file as $line )
    {
        
$words explode" "trim$line ) );
        foreach( 
$words as $word )
        {
            
$word ereg_replace"[^A-Za-z0-9]"""$word );
            if ( 
strlen$word ) > )
            {
                if ( !
in_array$word$unique_words ) )
                {
                    
$unique_words[] = $word;
                }
            }
        }
    }
}
foreach( 
$unique_words as $word )
{
    echo 
$word "\n";
}
?>
Enjoy. Now that you have WampServer, head over to PHP.net, read the documentation and learn something
ProG is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote