preg_replace to capitalize a letter after a quote
Posted
by Summer
on Stack Overflow
See other posts from Stack Overflow
or by Summer
Published on 2010-04-14T14:42:28Z
Indexed on
2010/04/14
14:42 UTC
Read the original article
Hit count: 451
I have names like this:
$str = 'JAMES "JIMMY" SMITH'
I run strtolower
, then ucwords
, which returns this:
$proper_str = 'James "jimmy" Smith'
I'd like to capitalize the second letter of words in which the first letter is a double quote. Here's the regexp. It appears strtoupper is not working - the regexp simply returns the unchanged original expression.
$proper_str = preg_replace('/"([a-z])/',strtoupper('$1'),$proper_str);
Any clues? Thanks!!
© Stack Overflow or respective owner