I have the following array.
$state = array("gujarat","andhra_pradesh","madhya_pradesh","uttar_pradesh");
Expected Output
$state = array("Gujarat","Andhra Pradesh","Madhya Pradesh","Uttar Pradesh");
I want to convert array values with each first character of a word with UpperCase and replace _ with space. So I do it using this loop and it working as expected.
foreach($states as &$state)
{
$state = str_replace("_"," ",$state);
$state = ucwords($state);
}
But my question is: is there any PHP function to convert the whole array as per my requirement?
array_mapit is another way. you said its working fine, why the change?foreachloop but I wantshortcode to implement it