Reputation: 1603
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?
Upvotes: 4
Views: 700
Reputation: 1041
because ucwords() Convert the first character of each word to uppercase and each word differ by space
if you used this one
echo ucwords('online/offline', '/');
than not work for
'echo ucwords ('online offline','/')`
you should pass all character that separate the word for e.g
echo ucwords('online/offline', '/, ');
Upvotes: 1
Reputation: 454
ucwords supports delimiter parameter:
echo ucwords('online/offline', '/');
Upvotes: 3
Reputation: 26844
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.
Upvotes: 9