zohaib Posted November 21, 2008 Share Posted November 21, 2008 Hi all, I want to count number of words in Doc ,rtf file How can i do this with php? any ideas? Link to comment https://forums.phpfreaks.com/topic/133618-count-number-of-words-in-doc-rtf-file/ Share on other sites More sharing options...
mtoynbee Posted November 21, 2008 Share Posted November 21, 2008 I believe you would need to use PHP COM. #Instantiate the Word component. $word = new COM("word.application") or die("Unable to instantiate Word"); $word->Visible = 1; $word->Documents->Open("c:/anydocument.doc"); $temp = $word->Dialogs->Item(228); $temp->Execute(); $numwords = $temp->Words(); echo $numwords; $word->Quit(); Note that this is the only way to get the word count accurately: $word->ActiveDocument->Words->Count; Will see all carriage returns and punctuation as words so is wildy innaccurate. http://php.chinaunix.net/manual/zh/ref.com.php Link to comment https://forums.phpfreaks.com/topic/133618-count-number-of-words-in-doc-rtf-file/#findComment-695255 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.