note 79956 deleted from function.strtoupper by bjori

From: Date: Fri, 21 Dec 2007 17:12:27 +0000
Subject: note 79956 deleted from function.strtoupper by bjori
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-133858@lists.php.net to get a copy of this message
Note Submitter: reber at innovatics dot de ---- Here the code to upper every first character in a string: $str = 'this is a long small string'; if (strlen($str) > 1) // str longer than one char? for ($i = 1; $i < strlen($str)-1; $i++) // loop all char if ($str[$i-1] == ' ') // is the char before a space? $str[$i] = strtoupper($str[$i]); // if true, upper it echo ucfirst($str); // at last upper the first char // Result = 'This Is A Long Small String'

« previous php.notes (#133858) next »