Re: detecting end of line - php 4.1.2
| From: | Kevin Stone | Date: | Fri, 21 Mar 2003 23:02:27 +0000 |
| Subject: | Re: detecting end of line - php 4.1.2 | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-140644@lists.php.net to get a copy of this message | ||
----- Original Message -----
From: "Paul Godard" <Paul@gondwanastudio.com>
To: "PHP" <php-general@lists.php.net>
Sent: Friday, March 21, 2003 3:53 PM
Subject: [PHP] detecting end of line - php 4.1.2
> Hi
>
> I am trying to get php 4.1.2 to read a Mac file (exported from
> FileMaker Pro) and split it into different lines using the following
> but php does not recognize the end of line. For some tech reason I
> cannot upgrade php now but I need to be able to read my Mac files
> now. What is the easiest : edit the Mac file and replace the end of
> line or modify the script below? In any case I need help to know
> exactly what to do.
>
> // first read the entire file
> $file = file($Export_ImageBank);
>
> // process each line in turn
> foreach ($lines as $line_num => $line) {
>
>
> // first split tab-separated fields
>
list($Image_ID,$Mark_Check,$Image_Good,$Image_VeryGood,$Image_ShortCodeOrgan
,$Image_Number,$Image_SubFolder,$Image_Format,$Image_MaxPxWidth,$Image_MaxPx
Height,$Image_Year,$Image_Month,$Image_Subject,$Image_CodeCountry,$Image_Reg
ion,$Image_Location,$Image_Collection,$Image_Caption,$Image_CodePrice)
> = explode("\t", $line);
>
> Please email me directly at Paul@gondwanastudio.com. Thanks.
>
> --
>
> Kind regards, Paul.
>
> Gondwana
> Info@gondwanastudio.com
> http://www.gondwanastudio.com
I take it the file is ending up as one whole line in $file? Try the atomic
reaction method..
$file = explode("\r", implode("\r", file($_Esport_ImageBank)));
implode() ensures $file is a string, not an array and explode() breaks the
string on Mac end-of-line characters. With any luck that'll work for you.
- Kevin