How to convert to capital string in php?
This post, we helps you convert string to capital string.
1. Code:
<?php
function convertToCapitalString($str){
$exp = explode(' ', $str);
$output = [];
foreach ($exp as $v) {
$v = trim($v);
if ($v == '') continue;
$output[] = strtolower($v[0]) . substr($v, 1);
}
return ucfirst(join(' ', $output));
}
$str = 'soltuts.com is Providing Php Tutorials';
echo convertToCapitalString($str);
?>
2. Example:
Input:
soltuts.com is Providing Php Tutorials
Output:
Soltuts.com is providing php tutorials