note 40617 modified in function.strpos by danbrown

From: Date: Sun, 17 May 2009 16:44:09 +0000
Subject: note 40617 modified in function.strpos by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-154885@lists.php.net to get a copy of this message
counting the occurrences of a substring, recursive-style instead of looping. <?php function countSubstrs($haystack, $needle) { return (($p = strpos($haystack, $needle)) === false) ? 0 : (1 + countSubstrs(substr($haystack, $p+1), $needle)); } ?> --was-- counting the occurrences of a substring, recursive-style instead of looping. <? function countSubstrs($haystack, $needle) { return (($p = strpos($haystack, $needle)) === false) ? 0 : (1 + countSubstrs(substr($haystack, $p+1), $needle)); } ?> http://php.net/manual/en/function.strpos.php

« previous php.notes (#154885) next »