Reputation: 4945
I am trying to figure out how to determine if an ' i ' by itself meaning there is a space on either side of it is lowercase and change that i to a capital I.
So far I have
$explode = str_replace(ctype_lower(' i '),' I ',$explode);
which is not working
Upvotes: 0
Views: 55
Reputation: 8583
I think a preg_replace
would suite this better that way you can use word bounds so it will match instances like i'm
. I'm assuming your are using this to correct miss typed instances of I
.
$explode = preg_replace("/\bi\b/", "I", $explode);
Upvotes: 0
Reputation: 59701
You don't need to call ctype_lower()
it will just replace the lower 'i' if it get's found in the string, just do this:
$explode = str_replace(' i ',' I ',$explode);
Upvotes: 3