Take this string:
Israel agrees to significant easing of Gaza blockade
I want to return the capitalised words, separated by a comma, like this:
Israel,Gaza
I imagine it must be possible. Any ideas?
Split the string into it's words with explode(' '), iterate through the words and check if the word is capitalized by checking if it's first letter ($str[0]) is the same as its uppercase variant (strtoupper($str[0])). You can fill an array with the results and then join(',') it
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With