I done a program to read text file, where content is
#Header#
name: Juicy
age: 25
@Header@
#Text#
user text here
@Text@
#End#
tel
fax
@End@
eof
And I read the text file
$filename = "/usr/local/file/rpt.txt";
$fp = fopen($filename , 'r');
$content = fgets($fp);
while(strcmp($c ontent,"@End@") <>0) {
$content = fgets($fp);
if(strcmp($cont ent, "#Text#")== 0){ //not match
$strPretext .= $content;
}//end if
//end while
I should get the data from #Text# until one line before @End@, but I get
nothing, I found that the strcmp for #Text# always not match when it read
through whole file.
I cant find out what goes wrong. Please advise.
Thanks.
#Header#
name: Juicy
age: 25
@Header@
#Text#
user text here
@Text@
#End#
tel
fax
@End@
eof
And I read the text file
$filename = "/usr/local/file/rpt.txt";
$fp = fopen($filename , 'r');
$content = fgets($fp);
while(strcmp($c ontent,"@End@") <>0) {
$content = fgets($fp);
if(strcmp($cont ent, "#Text#")== 0){ //not match
$strPretext .= $content;
}//end if
//end while
I should get the data from #Text# until one line before @End@, but I get
nothing, I found that the strcmp for #Text# always not match when it read
through whole file.
I cant find out what goes wrong. Please advise.
Thanks.
Comment