Character shift
Posted: Thu Jun 04, 2009 11:12 am
Hello,
I've been learning php in this online class but unfortunately I don't get much help if I don't understand something. We've been given this project to create a program that will translate a word into pig latin. It think I've gotten everything except I can't figure out how to shift the consonant at the beginning of the word to the end. Does anyone have any suggestions? Here is what I have so far.
Thanks!!!
I've been learning php in this online class but unfortunately I don't get much help if I don't understand something. We've been given this project to create a program that will translate a word into pig latin. It think I've gotten everything except I can't figure out how to shift the consonant at the beginning of the word to the end. Does anyone have any suggestions? Here is what I have so far.
Thanks!!!
Code: Select all
<?
function word_latin($pig_latin) {
$consonants = "^h";
$new_word = ereg_replace($consonants, " ", $pig_latin);
return $new_word;
}
$pre_latin = "hello";
$post_latin = word_latin($pre_latin);
echo $post_latin."ay";
?>