- substr: documentation ( source)
- stripos: documentation ( source)
<?php
$string = 'This is a string of words with multiple vowels.';
$found = false;
$newstr = "";
for ($i=strlen($string); $i >= 0 ; $i--) {
$chr = substr($string, $i, 1);
if (!$found && stripos("aeiou", $chr) !== false) {
$found = true;
continue;
}
$newstr = $chr . $newstr;
}
return $newstr;