php-general Digest 3 Sep 2012 16:57:12 -0000 Issue 7949

Topics (messages 318952 through 318957):

Re: array_push
        318952 by: John Taylor-Johnston

load rtf file
        318953 by: John Taylor-Johnston
        318954 by: tamouse mailing lists
        318955 by: Matijn Woudt
        318956 by: Tedd Sperling
        318957 by: Matijn Woudt

Administrivia:

To subscribe to the digest, e-mail:
        php-general-digest-subscr...@lists.php.net

To unsubscribe from the digest, e-mail:
        php-general-digest-unsubscr...@lists.php.net

To post to the list, e-mail:
        php-gene...@lists.php.net


----------------------------------------------------------------------
--- Begin Message ---

Frank Arensmeier wrote:
2 sep 2012 kl. 19.48 skrev John Taylor-Johnston:

Why not add two lines of code within the first loop?

$chunks = explode("-30-", $mystring);
foreach($chunks as $chunk) {
     preg_match_all("/News Releases\n(.+)/s", $chunk, $matches);
     foreach($matches[1] as $matched_text_line) {
        $mynewarray[] = $matched_text_line;
     }
}

Besides the regex, this is pretty basic php.

/frank
Thanks!
I'm still a newbie, (10 years later). I'm still fuzzy when it comes to arrays.
John

--- End Message ---
--- Begin Message --- I have a big giant RTF file. I could convert it to plain text. BUT can PHP do it for me?

Also:

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;
?> |

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?

--- End Message ---
--- Begin Message ---
On Mon, Sep 3, 2012 at 12:23 AM, John Taylor-Johnston
<jt.johns...@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.

--- End Message ---
--- Begin Message ---
On Mon, Sep 3, 2012 at 7:23 AM, John Taylor-Johnston
<jt.johns...@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 out of the box, but try google PHP RTF...

- Matijn

--- End Message ---
--- Begin Message ---
On Sep 3, 2012, at 1:23 AM, John Taylor-Johnston <jt.johns...@usherbrooke.ca> 
wrote:

> I have a big giant RTF file. I could convert it to plain text. BUT can PHP do 
> it for me?

Hell, even M$ can't do it!

I have tons of old Word RFT files that were orphaned by the installation of a 
newer of M$ Word. The upgrade actually deleted older versions of Word and then 
would not open the older files because of security concerns (they were create 
by an older version, duh). It was a nightmare -- as a result, I lost years of 
business correspondence. Now I make z text version of every document I write. 

If I wanted to get those old files back, I will have to set up an older 
computer, reinstall the older version of Word and then transfer those files, 
convert them to text, and bring them back. That's a lot of work because I 
trusted M$ to respect older files, but they don't. In short, don't trust M$.

Cheers,

tedd

_____________________
t...@sperling.com
http://sperling.com





--- End Message ---
--- Begin Message ---
On Mon, Sep 3, 2012 at 5:24 PM, Tedd Sperling <t...@sperling.com> wrote:
> On Sep 3, 2012, at 1:23 AM, John Taylor-Johnston <jt.johns...@usherbrooke.ca> 
> wrote:
>
>> I have a big giant RTF file. I could convert it to plain text. BUT can PHP 
>> do it for me?
>
> Hell, even M$ can't do it!
>
> I have tons of old Word RFT files that were orphaned by the installation of a 
> newer of M$ Word. The upgrade actually deleted older versions of Word and 
> then would not open the older files because of security concerns (they were 
> create by an older version, duh). It was a nightmare -- as a result, I lost 
> years of business correspondence. Now I make z text version of every document 
> I write.
>
> If I wanted to get those old files back, I will have to set up an older 
> computer, reinstall the older version of Word and then transfer those files, 
> convert them to text, and bring them back. That's a lot of work because I 
> trusted M$ to respect older files, but they don't. In short, don't trust M$.
>
> Cheers,
>
> tedd
>

Either they don't have respect to the older files, or they just don't
understand how the format works..
The same goes for opening '97-'03 files in Word 2010 version,
sometimes it's also all messed up.

Just a side note tedd, couldn't you just open those RTF files with
wordpad? IIRC it supports RTF and plain text (even in Win7)

- Matijn

--- End Message ---

Reply via email to