note 16611 added to function.substr-count
| From: | Baldurien at ifrance dot com | Date: | Tue, 06 Nov 2001 12:19:39 +0000 |
| Subject: | note 16611 added to function.substr-count | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-20514@lists.php.net to get a copy of this message | ||
(sorry if there are spam)
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. :)
--
http://www.php.net/manual/en/function.substr-count.php
http://master.php.net/manage/user-notes.php?action=edit+16611
http://master.php.net/manage/user-notes.php?action=delete+16611
http://master.php.net/manage/user-notes.php?action=reject+16611