Im making my own function to search for the total number of something. but it is not working propperly. function getNumberOfCounts gets the $fromIndex but not the searchWord
public function getNumberOfCounts( $searchWord, $fromIndex )
{
$index = $fromIndex;
$counter = 0;
while( $index <= $endPos )
{
$index++;
$pos = strpos( $this->text, $searchWord, ($index+1) );
if( $pos > $index )
{
$counter++;
$index = $pos;
}
else
break;
}
return $counter;
}
public function searchDemo()
{
$startPos = 11; // ex
echo "<br /> count= " . $this->getNumberOfCounts( "Lorem", $startPos );
}
They are both part of the same class ofc.
EDIT: i know there is some missing info, but if I try to print $searchWord on the first line of getNumberOfCounts nothing is outputted.