string - Uppercase for first letter with php -


how can convert uppercase following example :

title-title-title 

result should be:

title-title-title 

i tried ucwords converts this: title-title-title


i have this:

echo $title = ($this->session->userdata('head_title') != '' ? $this->session->userdata('head_title'):'our home page'); 

in particular string example, explode strings first, use function ucfirst() , apply exploded strings, put them again:

$string = 'title-title-title'; $strings = implode('-', array_map('ucfirst', explode('-', $string))); echo $strings; 

should straightforward on applying this:

$title = ''; if($this->session->userdata('head_title') != '') {     $raw_title = $this->session->userdata('head_title'); // title-title-title     $title = implode('-', array_map('ucfirst', explode('-', $raw_title))); } else {     $title = 'our home page'; }  echo $title; 

Comments

Popular posts from this blog

ruby on rails - RuntimeError: Circular dependency detected while autoloading constant - ActiveAdmin.register Role -

c++ - OpenMP unpredictable overhead -

javascript - Wordpress slider, not displayed 100% width -