cvs: pear /PHP_Compat/Compat/Function str_word_count.php

From: Date: Mon, 28 Feb 2005 11:45:29 +0000
Subject: cvs: pear /PHP_Compat/Compat/Function str_word_count.php
Groups: php.pear.cvs 
Request: Send a blank email to pear-cvs+get-29924@lists.php.net to get a copy of this message
aidan Mon Feb 28 06:45:29 2005 EDT Modified files: /pear/PHP_Compat/Compat/Function str_word_count.php Log: Fixes bug #3586 http://cvs.php.net/diff.php/pear/PHP_Compat/Compat/Function/str_word_count.php?r1=1.8&r2=1.9&ty=u Index: pear/PHP_Compat/Compat/Function/str_word_count.php diff -u pear/PHP_Compat/Compat/Function/str_word_count.php:1.8 pear/PHP_Compat/Compat/Function/str_word_count.php:1.9 --- pear/PHP_Compat/Compat/Function/str_word_count.php:1.8 Tue Jan 25 23:55:13 2005 +++ pear/PHP_Compat/Compat/Function/str_word_count.php Mon Feb 28 06:45:28 2005 @@ -15,7 +15,7 @@ // | Authors: Aidan Lister <aidan@php.net> | // +----------------------------------------------------------------------+ // -// $Id: str_word_count.php,v 1.8 2005/01/26 04:55:13 aidan Exp $ +// $Id: str_word_count.php,v 1.9 2005/02/28 11:45:28 aidan Exp $ /** @@ -25,14 +25,14 @@ * @package PHP_Compat * @link http://php.net/function.str_word_count * @author Aidan Lister <aidan@php.net> - * @version $Revision: 1.8 $ + * @version $Revision: 1.9 $ * @since PHP 4.3.0 * @require PHP 4.0.0 (user_error) */ if (!function_exists('str_word_count')) { function str_word_count($string, $format = null) { - if ($format != 1 && $format != 2 && $format !== null) { + if ($format !== 1 && $format !== 2 && $format !== null) { user_error('str_word_count() The specified format parameter, "' . $format . '" is invalid', E_USER_WARNING); return false; @@ -43,11 +43,11 @@ switch ($format) { case null: - return count($word_array); + $result = count($word_array); break; case 1: - return $word_array; + $result = $word_array; break; case 2: @@ -55,10 +55,13 @@ $word_assoc = array(); foreach ($word_array as $word) { $word_assoc[$lastmatch = strpos($string, $word, $lastmatch)] = $word; + $lastmatch += strlen($word); } - return $word_assoc; + $result = $word_assoc; break; } + + return $result; } }

« previous php.pear.cvs (#29924) next »