note 16593 deleted from function.substr-count by jimw
| From: | jimw@php.net | Date: | Mon, 05 Nov 2001 20:56:56 +0000 |
| Subject: | note 16593 deleted from function.substr-count by jimw | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-20491@lists.php.net to get a copy of this message | ||
Here is a function similar to the 'substr_count' from php4, which as the same name, same
action... :) And which is made for php3.
You have to replace underscore '_' by 'spaces' in each new line.
function substr_count( $sChaine, $sRechercher )
{
__$sChaine = strtoupper( $sChaine );
__$sRechercher = strtoupper( $sRechercher );
__$iPosition = strpos( $sChaine, $sRechercher );
__$iCounter = 0;
__if ( is_string( $iPosition ) && !$iPosition )
____$iCounter = 0;
__else
__{
____while ( strlen( $sChaine ) != 0 )
____{
______$iCounter++;
______$sChaine = substr( $sChaine, ( $iPosition + strlen( $sRechercher ) ) );
______$iPosition = strpos( $sChaine, $sRechercher );
______/* S'il n'y a plus de mot a rechercher */
______if ( is_string( $iPosition ) && !$iPosition )
________break;
____}
__}
__return $iCounter;
}
This was tested on a php3 server, which have the property to be a slow server (free.fr... sigh!)
For the notes, theres are in French. :)