Convert All Upper , to Lower with First Letter Upper

Discussion in 'PHP' started by sparksflying, May 24, 2007.

  1. #1
    Hi ,

    I have some fields with data in uppercase and i know I can use php function to convert *ALL* to lower ...http://ie.php.net/strtolower

    But any ideas how to keep the first letter capital and convert the rest???

    Hmmmmmm
     
    sparksflying, May 24, 2007 IP
  2. turiel

    turiel Peon

    Messages:
    148
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    0
    #2
    You can use the ucfirst() function.

    So ucfirst("blah");

    Will result in "Blah".
     
    turiel, May 24, 2007 IP
  3. tinkerbox

    tinkerbox Peon

    Messages:
    55
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #3
    $text = "hello world";
    echo strtoupper($text); // HELLO WORLD
    echo ucfirst($text); // Hello world
    echo ucwords($text); // Hellow World
     
    tinkerbox, May 24, 2007 IP
  4. zeljic

    zeljic Peon

    Messages:
    218
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Just another option:
    $str = "HELLO WORLD";
    echo ucfirst(strtolower($bar)); // Hello word
     
    zeljic, Jun 3, 2009 IP
  5. PoPSiCLe

    PoPSiCLe Illustrious Member

    Messages:
    4,623
    Likes Received:
    725
    Best Answers:
    152
    Trophy Points:
    470
    #5
    Except that the above should be:
    $str = "HELLO WORLD";
    echo ucfirst(strtolower($str)); //Hello World

    ;)
     
    PoPSiCLe, Jun 3, 2009 IP