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? Quote Link to comment 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 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.