PHP capitalize after dash

后端 未结 9 1595
长情又很酷
长情又很酷 2021-01-17 13:46
$q = durham-region;

$q = ucfirst($q);

$q = Durham-region;

How would I capitalize the letter after the dash (Durham-Region)? Would I have to spli

9条回答
  •  夕颜
    夕颜 (楼主)
    2021-01-17 14:30

    Thanks to the delimiter parameter of ucwords, since PHP 5.4.32 and 5.5.16, it is as simple as this:

    $string = ucwords($string, "-");
    

提交回复
热议问题