Jump to content

Counting problem


Ache

Recommended Posts

I have a text file and want to count on how many lines in it a certain string excists.For that I have written the following code, but it is not working.<?php $prk = $_POST['prk']; $myFile = "testFile.txt"; $fh = fopen($myFile, 'r'); $aantal = 0; while (!feof($fh)) { $theData = fgets($fh); $pos = strpos($theData, $prk); if ($pos === true) { $aantal++; } } fclose($fh); echo $aantal; echo "<br>\n";?>If I change $aantal++; with $aantal = $aantal + 1; it also doesn't workWhat am I doing wrong?

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...