Greetings. Tell please function PHP5 which defines presence of the end of a line (like !feof - for the file end).
Thanks in advance!)

Can you please describe your use case a little more so we have a better idea of what you are trying to accomplish?

You can read through a file line by line using fgets, but if you are trying to detect if a character is an end of line character, which varies (\n \r\n etc.), you would use something like fseek to progress the file pointer 1 character at a time and fread to capture the next byte and test it for being an EOL character.

commented: +++++++++++ +1

Yes. I want to read the file from character to character, amassing read in a variable of type string. Once I find the new line character - uses this variable in a mysql_query function.
Thanks to your response, I think it's possible to do so -

$fdata = fopen ($filename, "r+");
$str = '';	 
while (!feof($fdata))
{ 
  $simb = fgetc($fdata);
  if  ($simb = '/n')
  {
    $str = $str + $simb;
	mysql_query($str);
	$str = '';
  }
  else
  {
   str = $str + $simb;
  }
}

---------------------------------
but it is not clear - why are so many options -

\n \r\n

for example new string in Delphi is uniquely denoted by -

#13#10

It sounds like you're trying to read through a file line by line and then use the value of that line to perform a query.

Personally I prefer the SplFileObject assuming you're using php > 5.1.0

<?php
//Create SplFileObject instance of $filename
$file = new SplFileObject($filename);

//Set the drop new line flag so returned line value does not include \n etc.
$file->setFlags(SplFileObject::DROP_NEW_LINE);

//Foreach line in the file execute a query
foreach ($file as $line) {
    mysql_query($line);
}

I continue this thread.Are these lines equivalent? -

1)echo ($str."\r\n");
 2)echo ($str."<br>");

(Judging by the script - no)
Tell me please, what is my mistake?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.