RE: [PHP] extracting data from text file

2002-07-01 Thread Beverly Steiner

Here's one way assign each line:

";
echo "state is $state";
echo "city is $city";
echo "comapny is $company";
echo "division is $division";
echo "url is $url";
echo "email is $email";

fclose($whattoread);
?>


Bev

-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
Sent: Monday, July 01, 2002 5:17 PM
To: php-general
Subject: [PHP] extracting data from text file


Hello ,
I have a text file that looks like this. each entry is on a different
line I need to pull the data out of
it and put each line of data into its own variable

US
State
City
Company Name
Section 2
www.domain.com
[EMAIL PROTECTED]

I have trend this but it does not work properly

$fp = @fopen(file.txt,"r");
  $line = explode("\n",$fp);
  $valueC = "$line[0]";
  $valueST = "$line[1]";
  @fclose($fp);

-- 
Best regards,
 rdkurth  mailto:[EMAIL PROTECTED]


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] extracting data from text file

2002-07-01 Thread Pushkar Pradhan

Just use file(), this is most appropriate for reading file line by line.
http://www.php.net/manual/en/function.file.php
>
> On Monday, July 1, 2002, at 05:17  PM, [EMAIL PROTECTED] wrote:
>
> > I have trend this but it does not work properly
> >
> > $fp = @fopen(file.txt,"r");
> >   $line = explode("\n",$fp);
> >   $valueC = "$line[0]";
> >   $valueST = "$line[1]";
> >   @fclose($fp);
>
> What error messages are you getting?  I imagine that since you've
> suppressed the errors with the "@", you will need to remove this to give
> us any useful information.
>
> One other thing, has your file been saved with the appropriate line
> breaks for your server?  In some cases, a file may have DOS/Windows or
> Macintosh line breaks which are not \n but rather \r\n and \r
> respectively IIRC.
>
>
> Erik
>
>
>
>
> 
>
> Erik Price
> Web Developer Temp
> Media Lab, H.H. Brown
> [EMAIL PROTECTED]
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>

-Pushkar S. Pradhan


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] extracting data from text file

2002-07-01 Thread Erik Price


On Monday, July 1, 2002, at 05:17  PM, [EMAIL PROTECTED] wrote:

> I have trend this but it does not work properly
>
> $fp = @fopen(file.txt,"r");
>   $line = explode("\n",$fp);
>   $valueC = "$line[0]";
>   $valueST = "$line[1]";
>   @fclose($fp);

What error messages are you getting?  I imagine that since you've 
suppressed the errors with the "@", you will need to remove this to give 
us any useful information.

One other thing, has your file been saved with the appropriate line 
breaks for your server?  In some cases, a file may have DOS/Windows or 
Macintosh line breaks which are not \n but rather \r\n and \r 
respectively IIRC.


Erik






Erik Price
Web Developer Temp
Media Lab, H.H. Brown
[EMAIL PROTECTED]


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php