Login | Register  

Capitalize strings in PHP

by Scud   Friday, July 20, 2007 Rating:
 Vote this news:


If you're a developer and must update an old applications, you should play with strings and transform them. With some hacks of PHP we can capitalize strings. We may use ucwords functions in PHP. But if you try this function directly you can not see a sucessful transformation. First you need to transform all characters to lower case and later you must use this functions.
Ok let's see in in action:


$products_name = $product_info['products_name'];

$products_name = strtolower($products_name);

$products_name = ucwords($products_name);

echo $products_name;
?>


What we have done here. This is sample part of a oscommerce code. We have pulled some data from database and passed the value to $products_name variable. First we make it lowercase the value and later capitalized it.
That's all.

Happy Coding!




Dotnetindex.com is listed with 411asp.net
Dotnetindex.com is listed with aspin.com
Dotnetindex.com is listed with jspin.com
PHP, ASP, .NET, JSP Resources, Reviews







page counter
Copyright © 2007 Powered by GNews Publisher Positive. All rights reserved. Contact Us - Load Time: 0.05 second(s)