Capitalize only vowels in a string

I’ve search this and kept coming up with how to capitalize a whole string, or first letter of a string, but what if I wanted to pick out the vowels (a,e,i,o,u) of a string and only capitalize those?

Lets say the string is "You Never Know how much cake you can make "

[php]

<?php $string="Some String"; $newarray=array(); $i=0; foreach($string as $char) { if($char==a||$char==e||$char==i||$char==o||$char==u||) { $char=strtoupper($char) } $newarray[$i++]=$char; } ?>

[/php]

Not tested, but I hope you get the basic idea now. :slight_smile:

~Xzax

9th line missing ;

There is a simple code:

[php]
$string = “some string”;
$vowels = array(‘a’, ‘e’, ‘i’, ‘o’, ‘u’);
$after = str_replace($vowels, array_map(‘strtoupper’, $vowels), $string);
echo $after;
[/php]

Sponsor our Newsletter | Privacy Policy | Terms of Service