note 18341 modified in function.ucwords by imajes

From: Date: Fri, 18 Jan 2002 23:28:10 +0000
Subject: note 18341 modified in function.ucwords by imajes
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-25076@lists.php.net to get a copy of this message
This seems to be what people want: function uc_all($string) { $temp = preg_split('/(\W)/', $string, -1, PREG_SPLIT_DELIM_CAPTURE ); foreach ($temp as $key=>$word) { $temp[$key] = ucfirst(strtolower($word)); } return join ('', $temp); } [ed note: fixed the code to be correct] --was-- This seems to be what people want: function uc_all($string) { $temp = preg_split('/(\W)/', $string, -1, PREG_SPLIT_DELIM_CAPTURE ); print_r($temp); foreach ($temp as $key=>$word) { $temp[$key] = ucfirst($word); } return join ('', $temp); } http://www.php.net/manual/en/function.ucwords.php

« previous php.notes (#25076) next »