Contador de línea de archivo PHP Word

I need to make a PHP function that will count the number of lines in a Word File (.doc, docx)

This code does not seem to work correctly for me :

 $name = 'test.doc';                
 $line_count = count(file($name));
 echo $line_count

My guess is that this script does not work well with .doc or .docx but works good in .txt files. Are there any alternatives available out there? Tnx!

preguntado el 24 de agosto de 12 a las 07:08

Uhmm, I don't think you can do that with a .doc file, as it is a Microsoft Office file and it's contents are not simple text. -

I really hope you are not implying that there is no solution available :(( - maybe this can help you. -

1 Respuestas

Solo .docx can be opened with simple PHP ya que es un zip archivo:

$zip = new ZipArchive;
if ($zip->open('test.docx') === TRUE) {
    $xml = $zip->getFromName('docProps/app.xml');
} else {
    $xml = false;

    $xml = simplexml_load_string($xml);
    echo $xml->Lines;

Respondido 24 ago 12, 07:08

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.