Hi friends
I have a problem, problem is that I have an array in php like as :
$arr=array("ram","mohan","shyam","vineet");
I want to first character of every word will be in upper case ? Please tell me anyone ,how to do this ?
Please help me ?
Thanks
Make first character in uppercase of an array element in PHP
4 Answers
Know the answer? Post it. Somebody with the same question will find it here.


Akkiraju IvaturiRank #473 · 5.3K reputationPosted Sep 18, 2012, 7:02 AM EDT
You need to loop through all the elements in the array and use the function to make the first letter of word as uppercase and then add it to another array.
Let me know if you have any questions.
Satyapriya NayakRank #47 · 31.5K reputationPosted Sep 18, 2012, 8:17 AM EDT
Try this...
$arr=array("ram","mohan","shyam","vineet");
foreach ($arr as $key => $val)
{
print_r(ucwords($val));
echo '
';
}
?>
Thanks
If this post helps you mark it as answer
Rohatash KumarRank #12 · 57.7K reputationPosted Sep 18, 2012, 7:36 PM EDT
Firstly You need foreach loop to all the element of array and use the function ucwords. it convert first letter of word in uppercase.
Rohatash
Vineet Kumar SainiRank #257 · 9.8K reputationPosted Sep 18, 2012, 10:27 PM EDT