php - I have a word doc. i want to get word count per page of word doc? -
i find solution per line cant find page break; confused lot. docx cant find exact word count.
function read_doc($filename) { $filehandle = fopen($filename, "r"); $line = @fread($filehandle, filesize($filename)); $lines = explode(chr(0x0d), $line); $outtext = ""; foreach ($lines $key => $thisline) { if( $key > 11 ){ var_dump($thisline); $pos = strpos($thisline, chr(0x00)); if (($pos !== false) || (strlen($thisline) == 0)) { continue; } else { var_dump($thisline); $text = preg_replace("/[^a-za-z0-9\s\,\.\-\n\r\t@\/\_\(\)]/", "", $thisline); var_dump($text); } } } return $outtext;
}
implementing own code doesn't sound idea. recommend using external library such phpword. should allow convert file plain text. then, can extract word count it.
also, external library such adds support number of file formats, not restricting word 97-2003.
Comments
Post a Comment