Reputation: 91
This doesn't seem to work correctly for me, it always returns an empty string. I could not find the error that I made.
function title($page){
$i=0;
$title="";
foreach ($page as $c){
if ($i===0){
ucfirst($c);
}
if ($c=="_"){
$c=" ";
}
$i++;
array_push($title,$c);
}
return $title;
}
Upvotes: 0
Views: 63
Reputation: 4167
Try
function title($page)
{
return ucfirst(str_replace('_', ' ', $page));
}
Upvotes: 2