Re: load rtf file
| From: | tamouse mailing lists | Date: | Mon, 03 Sep 2012 06:57:33 +0000 |
| Subject: | Re: load rtf file | ||
| References: | 1 2 3 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-318954@lists.php.net to get a copy of this message | ||
On Mon, Sep 3, 2012 at 12:23 AM, John Taylor-Johnston
<jt.johnston@usherbrooke.ca> wrote:
> I have a big giant RTF file. I could convert it to plain text. BUT can PHP
> do it for me?
Not directly, although there might be libraries out there to do it,
but none that I'm aware of off-hand. Perl, of course does this with
RTF::TEXT::Converter <
http://search.cpan.org/~sargie/RTF-Parser-1.09/lib/RTF/TEXT/Converter.pm
>. To use this, you'd have to hand off the processing to a perl script
using shell_exec, proc_open, etc.
> I want to read the text file into a string. This does the job well, right?
> http://php.net/manual/en/function.file-get-contents.php
>
> This is it? Not more complicated?
>
> |<?php
> $homepage =
> file_get_contents('http://www.example.com/text.txt');
> echo $homepage;
> ?> |
Not really complicated, *however* there is a php.ini option that must
be set for this to work: <
http://www.php.net/manual/en/filesystem.configuration.php#ini.allow-url-fopen
>
> What about this?
> http://www.php.net/manual/en/function.file.php
>
> ||<?php
> |$lines = file('http://www.example.com/');|
> |echo $lines;
> ?>|
>
> Is there any big difference?
*HUGE* difference:
* file_get_contents returns a single *string* with the entire content.
* file returns an *array* of lines.
Change your above snippets to use 'var_dump($lines);' instead of 'echo
$lines;' to see the structural difference.