Bir şeyin toplam sayısı için aramak için kendi fonksiyonunu yapıyor Im. ama propperly çalışmıyor. fonksiyonu getNumberOfCounts $ fromIndex öğesini değil SearchWord alır
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 );
}
Her ikisi de aynı sınıf OFC parçasıdır.
EDIT: i know there is some missing info, but if I try to print $searchWord on the first line of getNumberOfCounts nothing is outputted.