How to read text data from .docx in PHP

Back to questions answers.

chittivenureddy    (2010-05-20)


How to read text data from .docx in PHP

hi all
how to read a .docx file  in PHP
this is my code but its return some junk data

$fileHandle = fopen("test.docx", "r");
    $line = @fread($fileHandle, filesize($userDoc)); 
    $lines = explode(chr(0x0D),$line);
    $outtext = "";
    foreach($lines as $thisline)
        $pos = strpos($thisline, chr(0x00));
        if (($pos !== FALSE)||(strlen($thisline)==0))
          } else {
            $outtext .= $thisline." ";

  $outtext = preg_replace("/[^a-zA-Z0-9\s\,\.\-\n\r\t@\/\_\(\)]/","",$outtext);

//Output :  Gino/1Af3TI SWY Q, e(4DG7F.urxCs_q4hJ HFRpRya 3F8IP)wzJj4evPmgdg1T)tJ dXiJ(x( I_TS 1EZBmU/xYy5g/GMGeD3Vqq8K)fw9 xrxwrTZaGy8IjbRcXI u3KGnD1NIBs RuKV.ELM2fi V vlu8zH (W )6-rCSj id DAIqbJx6kASht(QpmcaSlXP1Mh9MVdDAaVBfJP8 AVf mA E l(0W8KqI VRzbCp8jY08qFG6rHZy -_ obl r5

can any one help me.
advance Thanks

(more options below)

*jifforang    (2011-04-08 12:45:49)
How to read text data from .docx in PHP

not designed for .docx format, this function reads .doc format. If you want to read docx, try here:


Not sure of the output you will get (not used it myself) but should give you the text, cleaned. The other option you have is MSDN to find out the xml format and create a function to parse the info you require.



*mukugu    (2014-12-19 18:06:39)
5 years ago

lgogogiiiiii hpohoph  pjpoi p po p pohophoopihopih iiiiiiiiiiiiiiiiiiiiiiiiiiol

See also

More websites

You must register to see these links, as this is a collaborative page, then you may change the order of the links by clicking the icons before the titles.

Other websites

The following links might be less relevant, please change their ranks if you find them useful.

 Reading the clean text from DOCX and ODT PHP
tutcity > tutorial/reading the clean text from docx and odt.23916
  1. In this article we will resolve the task of reading the plain text
 Read PDF and Word DOC Files Using PHP
davidwalsh > read pdf doc file php

Currently I’m working in a project for that I have to read and...

 read file .docx or .doc in php? | keyongtech
keyongtech > 5558956 read file docx or doc

How do I create a DOCX file that has a chart and the datasource is in...
How do I read a document with a file extention of...

 List of software that supports Office Open XML - Wikipedia, the free encyclopedia
en.wikipedia > wiki/List of software that supports Office Open XML

This page was last modified on 13 October 2010 at...

 read file .docx or .doc in php?
1 script > forums/read file docx or doc in php article124420 7.htm

[I filter all Goggle Groups posts, so any reply may be automatically...
Unless you got Microsoft's internal documentation off the net or...
Required Permissions to Append to File But Not Read...

 How to easily extract text from .docx ...really... [Archive] - Ubuntu Forums
ubuntuforums > archive/index.php/t 534112

HI I am in a rather irksome situation, I teach at a junior...

 php 2 docx softwares - Free download - FreeWares
lisisoft > tools/php 2 docx

ynamic helpcontext andwork withcodelobster phpphp edition,smarty...
PHP Coder 1 by ST Software (Lorant Szasz-Toth)- Software...

 Free php extract text doc docx rtf Download - php extract text doc docx rtf Files
software.informer > getfree php extract text doc docx rtf

Editor is an advanced application having a faster and quick...
TO CHM Generator is a Help Authoring Tool that can convert Word...

 read file .docx or .doc in php? - PHP
daniweb > forums/thread278505

how to use a external javascript file (like external CSS) in...
No one has posted to this discussion for at least three...

 Matt Thommes / Read Microsoft Office 2007 files with PHP
matthom > archive/2010/04/14/read microsoft office 2007 files with php

you can then uncompress that, and view the individual files...
function validate_feedback() { var feedback_form =...

 Indexing Word 2007 (docx) files with Zend_Search_Lucene
blog.maartenballiauw > post/2008/02/Indexing Word 2007 (docx) files with Zend Se

Code performance analysis in Visual Studio 2008...
Introducing Windows Azure Companion – Cloud for the...

 Reading the clean text from DOCX and ODT with PHP - Tutorialized
tutorialized > tutorial/Reading the clean text from DOCX and ODT with PHP/55040

// Ad Setting, Mandatory _ad_custkey =...
function comments(id) { var x =...

 Reading from a Word Document with COM in PHP
drewd > 2007/01/25/reading from a word document with com in php

I've already use this code but the problem is that there's a fatal...
Below you see how to get the full path if the script gives an error...

 How to fetch .DOC or .DOCX file in php - Mombu the Php Forum
mombu > php/php/t

 Reading and replacing text in Word DocX and Excel XlsX documents using Ruby « SmartLogic Solutions Blog
blog.smartlogicsolutions > 2008/07/09/reading and replacing text in word docx an

Reading and replacing text in Word DocX and Excel XlsX documents...
Introducing environmentalist: an intuitive, environment-focused...


Guest name   (option)     Register
Please sum : 1986 + nine  

Trackbacks : If you talked about this article in your blog or website, you may instantly get a backlink 
There's no trackback at the moment.