note 42431 added to function.count-chars

From: Date: Sun, 16 May 2004 19:08:21 +0000
Subject: note 42431 added to function.count-chars
Groups: php.notes 
Request: Send a blank email to php-notes+get-69672@lists.php.net to get a copy of this message
After much trial and error trying to create a function that finds the number of unique characters in a string I same across count_chars() - my 20+ lines of useless code were wiped for this: <? function unichar($string) { $two= strtolower(str_replace(' ', '', $string)); $res = count(count_chars($two, 1)); return $res; } /* examples :: */ echo unichar("bob"); // 2 echo unichar("Invisibility"); //8 echo unichar("The quick brown fox slyly jumped over the lazy dog"); //26 ?> I have no idea where this could be used, but it's quite fun ---- Manual Page -- http://www.php.net/manual/en/function.count-chars.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+42431 Delete -- http://master.php.net/manage/user-notes.php?action=delete+42431&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+42431&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#69672) next »