Funksie substr_count

Die funksie substr_count tel hoeveel keer 'n substring in 'n string voorkom. Dit werk slegs korrek met Latynse karakters (enkelbyte-karakters).

Sintaksis

phpsubstr_count(string $haystack, string $needle, int $offset = 0, ?int $length = null): int

Voorbeeld

Laat ons tel hoeveel keer die substring 'test' in ons string voorkom:

php<?php
  echo substr_count('test www test', 'test');  
?>

Uitvoer van die kode:

php2

Sien ook