???? ???????? on 2012-04-23 14:51:39
If I might —perhaps you should consider adding a few images. I don’t mean to disrespect what you’ve said ; its very enlightening, indeed. However, I think would respond to it more positively if they could be something tangible to your ideas
Brett Zamir on 2011-09-14 10:53:39
@Dennis: Though I agree that could be useful in some situations, we are following PHP behavior.
Dennis on 2011-09-13 17:17:57
there is a mistake: the func wont turn THIS into This. So you should first make the entire string tolowercase.. fix.. publishing this comment is unnecessary
Dj on 2011-07-16 18:49:11
Why just dont use:

return str.charAt(0).toUpperCase() + str.substr(1);
instead of assign the value to f to later return it
Lucas Souza on 2010-07-26 16:43:04
Thank you, man. That was really helpful.
Kevin van Zonneveld on 2009-01-13 01:42:41
@ Brett Zamir: Beautiful man. If you keep this pace you may even beat Onno ;) Hm, wrong page, but strange that your previous post didn't come through. There is nothing in my spamfilter. Maybe you had different tabs open, so that captcha didn't match (there's one valid per session), and you closed the tab without noticing. Happened to me once :)
Brett Zamir on 2009-01-12 01:42:35
Here's lcfirst... It looks like you don't need the 2nd argument to substr (also in ucfirst) when you are extracting to the end...

function lcfirst( str ) {
    // http://kevin.vanzonneveld.net
    // *     example 1: lcfirst('Kevin Van Zonneveld');
    // *     returns 1: 'kevin Van Zonneveld'
 
    str += '';
    var f = str.charAt(0).toLowerCase();
    return f + str.substr(1);
}
alert(lcfirst('Kevin Van Zonneveld'))
and here's strcspn (for measuring the length of continuous sentences spoken by guests on C-SPAN):
function strcspn (str, mask, start, length) {
    start = start ? start : 0;
    var count = (length && ((start + length) < str.length)) ? start + length : str.length;
    strct:
    for (var i=start, lgth=0; i < count; i++) {
        for (var j=0; j < mask.length; j++) {
            if (str[i].indexOf(mask[j]) !== -1) {
                continue strct;
            }
        }
        ++lgth;
    }
    return lgth;
}

Kevin van Zonneveld on 2009-03-08 19:55:55
What you're describing sounds more like ucwords(). Please check the PHP manual.
Zorg on 2009-03-05 07:02:50
That isn't how ucfirst works in PHP, ucfirst makes the first letter of EVERY word uppercase... not just the first letter of the string.