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!
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!



