Re: [PHP] Re: Using File to count number of lines

2005-08-04 Thread Al

Brandon Ryan wrote:
 Are you running this php code in windows, where a line break is made up of 
a carriage return and a line feed? The file was probably created on 
unix/linux where the line break is just a line feed. If you try to read this 
file in windows, it will think everything is on one line. You either have to 
replace all line feeds with carriage return and then line feed, or read it 
in and parse it. 
 Brandon
 On 8/4/05, Al <[EMAIL PROTECTED]> wrote: 


Tom Chubb wrote:


I'm having a problem with the following code:

http://www.mysite.co.uk/mailing_list_database.list";;
$lines = count(file($file));
echo "$lines ";
?>

I'm trying to show the number of subscribers to my visitors from a 
text file, but it returns a value of 1 when it should be 5000.

I think it's to do with recognising the line break but I don't know
how to make it work!?!

(I've looked on php.net  for the file, fopen & count 


functions and


can't find anything, although fopen mentions using the -t mode.
Any ideas?

Thanks,

Tom


$count= substr_count($file_str, "\n"); 


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






Windows is \r\n; unix/linux \n; MAC \r.  So the \n gets Windows and Unix/linux/ 
 If it's MAC or can be. then replace all

\r with \n first.

e.g., $str= preg_replace("%(\r\n|\r|\n)%", "\n", $str);

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



[PHP] Re: Using File to count number of lines

2005-08-04 Thread Brandon Ryan
 Are you running this php code in windows, where a line break is made up of 
a carriage return and a line feed? The file was probably created on 
unix/linux where the line break is just a line feed. If you try to read this 
file in windows, it will think everything is on one line. You either have to 
replace all line feeds with carriage return and then line feed, or read it 
in and parse it. 
 Brandon
 On 8/4/05, Al <[EMAIL PROTECTED]> wrote: 
> 
> Tom Chubb wrote:
> > I'm having a problem with the following code:
> >
> >  > $file = " http://www.mysite.co.uk/mailing_list_database.list";;
> > $lines = count(file($file));
> > echo "$lines ";
> > ?>
> >
> > I'm trying to show the number of subscribers to my visitors from a 
> > text file, but it returns a value of 1 when it should be 5000.
> > I think it's to do with recognising the line break but I don't know
> > how to make it work!?!
> >
> > (I've looked on php.net  for the file, fopen & count 
> functions and
> > can't find anything, although fopen mentions using the -t mode.
> > Any ideas?
> >
> > Thanks,
> >
> > Tom
> 
> $count= substr_count($file_str, "\n"); 
> 
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 
>


[PHP] Re: Using File to count number of lines

2005-08-04 Thread Al

Tom Chubb wrote:

I'm having a problem with the following code:

$file = "http://www.mysite.co.uk/mailing_list_database.list";; 
$lines = count(file($file));  
echo "$lines "; 
?>


I'm trying to show the number of subscribers to my visitors from a
text file, but it returns a value of 1 when it should be 5000.
I think it's to do with recognising the line break but I don't know
how to make it work!?!

(I've looked on php.net for the file, fopen & count functions and
can't find anything, although fopen mentions using the -t mode.
Any ideas?

Thanks,

Tom


$count= substr_count($file_str, "\n");

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



[PHP] Re: Using @file

2001-12-18 Thread Chris Lee

haha, I bet it cant resolve, and I doubt it works on other machines :)

www.myserver,com
www.myserver.com

see the diff? ditch the comma and put a period in insted :) trust me it
happens to the best of us.

--

  Chris Lee
  [EMAIL PROTECTED]



"Jeff Lewis" <[EMAIL PROTECTED]> wrote in message
013901c181b8$a4acd400$76a1a8c0@LEWISJCIT">news:013901c181b8$a4acd400$76a1a8c0@LEWISJCIT...
I am using this line in part of my code but am getting an error that looks
like below:

Code:
$serverDetails =
@file("http://www.myserver,com/versions.php?l=$scripturl&v=$version";);

Error:
2: php_network_getaddresses: gethostbyname failed
(c:\inetpub\wwwroot\yabbse\Sources\Admin.php ln 43)

What would be causing this error?  It works on some machines but not others?

Jeff




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]