grumpy
08-08-2008, 10:11 PM
I am trying to extract vowels from a string. One thing is to replace anything that is not a,e,i,o,u with "".
$fname_out = "test";
$vowels = array ('a', 'e', 'i', 'o', 'u');
One option (does not work) I considered:
$vow_fname = preg_replace(array('/^[^$vowels]+$/'), '', $fname_out);
The other (does not work):
$vow_fname = preg_replace('/^[^aeiou]+$/', '', $fname_out);
And another (does not work):
$vow_fname = str_replace(!($vowels), "", $fname_out);
Could you please suggest the right solution. I have been scouring php.net and other sites, but cannot seem to get the solution :(
Thank you! :)
Bo
$fname_out = "test";
$vowels = array ('a', 'e', 'i', 'o', 'u');
One option (does not work) I considered:
$vow_fname = preg_replace(array('/^[^$vowels]+$/'), '', $fname_out);
The other (does not work):
$vow_fname = preg_replace('/^[^aeiou]+$/', '', $fname_out);
And another (does not work):
$vow_fname = str_replace(!($vowels), "", $fname_out);
Could you please suggest the right solution. I have been scouring php.net and other sites, but cannot seem to get the solution :(
Thank you! :)
Bo