Re: Capitalizing the first letter

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello,
    In PHP ucfirst() function make a string's first character uppercase. But 
ralph smith have two words respectivetely ralph and smith. For this reason, 
if you call the ucfirst("ralph smith") function, you cannot see the Ralph 
Smith. You see the Ralph smith. If you want to see Ralph Smith string, you 
should use explode() function. With this functions, you returns an array of 
strings, each of which is a substring of string formed by splitting it on 
boundaries formed by the string delimiter.In the ralph smith delimeter 
characeter is blank line. You can use like a following examples in your 
code:)

<?php
    $yourname = "ralph smith";

    $name = explode (" ", $yourname);

    $yournewname = ucfirst( $name[0] ) . " " . ucfirst ( $name[1] );

    echo ( $yournewname );
?>

-- 
Haydar TUNA
Republic Of Turkey - Ministry of National Education
Education Technology Department Ankara / TURKEY
Web: http://www.haydartuna.net

"Todd Cary" <todd@xxxxxxxxxxxxxxxxxx> wrote in message 
news:B5.10.34414.CB0B6F54@xxxxxxxxxxxxxxx
>I would like to write a filter that takes the text "smith" or "SMith" and 
>returns "Smith"; same for "ralph smith".  Is the a good source on using 
>filters this way?
>
> Thank you... 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux