Monday 5 May 2008

PHP first letter of each word is capitalized

from HERE

function formatArray(s:String):String { // rraWrd is array to hold split values from passed string parameter. var rraWrd:Array = s.split(" "); // stgNew is a string into which to concatenate the new full sentence. var stgNew:String = ""; var nbrLen = rraWrd.length; for (var i:Number = 0; i < nbrLen; i++) { rraWrd[i] = rraWrd[i].substring(0, 1).toUpperCase() + rraWrd[i].substring(1); stgNew += (i < nbrLen - 1) ? rraWrd[i] + " " : rraWrd[i]; } return stgNew;}//var stgSentence:String = "This is not a love song";trace("Before: " + stgSentence);stgSentence = formatArray(stgSentence);trace("After: " + stgSentence);

No comments: