note 9354 added to substr_count

From: Date: Sat, 28 Oct 2000 19:42:59 +0000
Subject: note 9354 added to substr_count
Groups: php.notes 
Request: Send a blank email to php-notes+get-7161@lists.php.net to get a copy of this message
This fonction do the same thing that substr_count(). It is useful when working with PHP3. function substr_count($haystack, $needle, $offset = 0) { $i = 0; $count = 0; while ($i==0) { $longueur = strlen($haystack); $position = strpos($haystack, $needle, $offset); if ($position && ($offset + strlen($needle)) < $longueur) { $offset = $position+strlen($needle); $count++; } else { $i++; } } return $count; } http://www.php.net/manual/function.substr-count.php

« previous php.notes (#7161) next »