Reply to Re: strcmp problem

Your name:

Reply:


Posted by Rex on 11/18/08 11:43

Some observations: When reading a file you can use the funciton
feof() to check if a file pointer has reached the end of file marker.
This is useful when looping thru a file's contents.
I dont believe the inital fgets is needed -- just grab the first
line in the loop.
Also, instead of using the binary string comparision function use
the == operator and trim $contents to remove any uneeded whitespace
chars.
I'm not sure if the following listing is what you're looking for
as $strPretext only contains "#Text#" once the code is executed but i
think it's a step in the right direction.
If you're looking for the line after the "#Text#" line just do
another $content = fgets($fp); (line read) inside the if stmnt.



$filename = "/usr/local/file/rpt.txt";
$fp = fopen($filename, 'r');
$strPretext = "";

while( !feof($fp) ) {
$content = fgets($fp);
if( trim($content) == "#Text#") {
$strPretext .= $content;
}
}

echo $strPretext;

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация