Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ucwords doesn't work when After Slash (/) Symbol

Tags:

string

php

I write this code

echo ucwords('online/offline');

expected result : Online/Offline

result: Online/offline

How to make first letter after slash symbol become capital letter without adding spaces?

like image 365
Wildan Muhlis Avatar asked Sep 11 '25 18:09

Wildan Muhlis


2 Answers

You can add delimiters on the second paremeter of ucwords

echo ucwords('online/offline', '/');

This will result to:

Online/Offline 

Documentation: http://php.net/manual/en/function.ucwords.php

The optional delimiters contains the word separator characters.

like image 66
Eddie Avatar answered Sep 13 '25 08:09

Eddie


ucwords supports delimiter parameter:

echo ucwords('online/offline', '/');
like image 38
Razon Yang Avatar answered Sep 13 '25 08:09

Razon Yang