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

From: Date: Sat, 26 Jun 2004 07:56:21 +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-21142@lists.php.net to get a copy of this message
schst Sat Jun 26 03:56:21 2004 EDT Modified files: /pear/PHP_Compat/Compat/Function str_word_count.php Log: fixed coding style & whitespace issues http://cvs.php.net/diff.php/pear/PHP_Compat/Compat/Function/str_word_count.php?r1=1.3&r2=1.4&ty=u Index: pear/PHP_Compat/Compat/Function/str_word_count.php diff -u pear/PHP_Compat/Compat/Function/str_word_count.php:1.3 pear/PHP_Compat/Compat/Function/str_word_count.php:1.4 --- pear/PHP_Compat/Compat/Function/str_word_count.php:1.3 Sat Jun 26 03:28:07 2004 +++ pear/PHP_Compat/Compat/Function/str_word_count.php Sat Jun 26 03:56:21 2004 @@ -16,7 +16,7 @@ // | Authors: Aidan Lister <aidan@php.net> | // +----------------------------------------------------------------------+ // -// $Id: str_word_count.php,v 1.3 2004/06/26 07:28:07 aidan Exp $ +// $Id: str_word_count.php,v 1.4 2004/06/26 07:56:21 schst Exp $ // @@ -27,7 +27,7 @@ * @package PHP_Compat * @link http://php.net/str_word_count * @author Aidan Lister <aidan@php.net> - * @version $Revision: 1.3 $ + * @version $Revision: 1.4 $ * @since PHP 4.3.0 * @require PHP 4.0.1 (trigger_error) */ @@ -40,28 +40,27 @@ return false; } - $word_string = preg_replace('/[0-9]+/', '', $string); - $word_array = preg_split('/[^A-Za-z0-9_\']+/', $word_string, -1, PREG_SPLIT_NO_EMPTY); + $word_string = preg_replace('/[0-9]+/', '', $string); + $word_array = preg_split('/[^A-Za-z0-9_\']+/', $word_string, -1, PREG_SPLIT_NO_EMPTY); - switch ($format): - case null: - return count($word_array); - break; - - case 1: - return $word_array; - break; - - case 2: - $lastmatch = 0; - $word_assoc = array(); - foreach ($word_array as $word) { - $word_assoc[$lastmatch = strpos($string, $word, $lastmatch)] = $word; - } - return $word_assoc; - break; - - endswitch; + switch ($format) { + case null: + return count($word_array); + break; + + case 1: + return $word_array; + break; + + case 2: + $lastmatch = 0; + $word_assoc = array(); + foreach ($word_array as $word) { + $word_assoc[$lastmatch = strpos($string, $word, $lastmatch)] = $word; + } + return $word_assoc; + break; + } } }

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