I have this PHP code:
$myfile = fopen("index.txt", "r") or die("Unable to open file!");
//rewind($myfile);
fseek($myfile, 0);
while(!feof($myfile)) {
$line=fgets($myfile);
echo $line;
echo strpos($line,":");
echo "<br />";
}
fclose($myfile);
index.txt contains the following data:
:a
1:b
2:c
result:
:a 3
1:b 1
2:c1
I'm having problem with the function strops
, it doesn't give the accurate position number.
As you can see in the result, I get the number 3
while it should be 0
and there is a white space added between the letter a
& the number 3
(and between the letter b
& the number 1
). Why is that?
As you can see above, I tried to set the file pointer position to 0, but didn't work.
Thanks.