tvks Posted March 16, 2007 Share Posted March 16, 2007 Hi all, I am right now stuck with a project of selecting multiple files (File format: only doc, txt and rtf) and onclick of the submit, I must generate a report on how many characters, words, line breaks, sentences are there in each of the selected files. Thanx for any help, Regards tvks Link to comment https://forums.phpfreaks.com/topic/42945-doing-wordcount-in-php-of-files-like-doc-rtf-txt/ Share on other sites More sharing options...
Barand Posted March 16, 2007 Share Posted March 16, 2007 The text file bit is easy <?php $txt = file_get_contents('myfile.txt'); $chars = count_chars($txt); $w = str_word_count($txt); $c = strlen($txt) ; echo "Characters : $c <br>"; echo "Words : $w <br>" ; echo "Sentences : $chars[46] <br>"; echo "Newlines : $chars[13] <br>"; ?> For the Word and rtf files you will need COM objects. The properties and methods available for word documents can be at the MSDN site. Try Googling "PHP COM WORD" Link to comment https://forums.phpfreaks.com/topic/42945-doing-wordcount-in-php-of-files-like-doc-rtf-txt/#findComment-208694 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.