note 37984 deleted from function.count-chars by didou

From: Date: Thu, 04 Dec 2003 09:38:53 +0000
Subject: note 37984 deleted from function.count-chars by didou
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-61394@lists.php.net to get a copy of this message
Note Submitter: bishop ---- Here's a very simple frequency counter I use most often in statistical apps: function count_item(&$freq, $item, $inc = 1) { if (! is_array($freq)) { $freq = array (); } $freq[$item] = (isset($freq[$item]) ? ($freq[$item] += $inc) : $inc); return true; } The point here is this function saves you the isset() check on the assignment every single time you wish to count frequency. This is important if you care about getting rid of all of PHPs warnings, including those about uninitialized variables.

« previous php.notes (#61394) next »