English to Piglatin translator needed.
I want to have a piglatin script that you can enter text in a comment and have it translate it from English to Piglatin.
I have found one but it reads from a text file and writes to a text file.
I was hoping someone could edit this and have it read from the textbox and display on the screen.
I also want a couple other mods but this is a start.
I will pay for someone to complete this.
Extra - If you know how to do a Piglatin to English translator script that would be helpful too.
I want to have a piglatin script that you can enter text in a comment and have it translate it from English to Piglatin.
I have found one but it reads from a text file and writes to a text file.
I was hoping someone could edit this and have it read from the textbox and display on the screen.
I also want a couple other mods but this is a start.
I will pay for someone to complete this.
Extra - If you know how to do a Piglatin to English translator script that would be helpful too.
PHP:
piglatin.php code
#!/usr/local/bin/php
<?php
/* This program translates one line of text in a file called oneline to pig latin. */
/* It includes examples of reading from files, defining functions, associative arrays */
/* and string functions. */
/* The rotate function shifts the charaters in a string one position to the left */
/* bringing the first character around to the end of the string */
function rotate($a)
{
$rotatedstring = substr($a,1,strlen($a)-1).substr($a,0,1);
return $rotatedstring;
}
/* The alphabet array is an associative array with the index being the letter and */
/* the value being either "vowel" or "consonant." */
$alphabet=array(
'a'=>"vowel",
'b'=>"consonant",
'c'=>"consonant",
'd'=>"consonant",
'e'=>"vowel",
'f'=>"consonant",
'g'=>"consonant",
'h'=>"consonant",
'i'=>"vowel",
'j'=>"consonant",
'k'=>"consonant",
'l'=>"consonant",
'm'=>"consonant",
'n'=>"consonant",
'o'=>"vowel",
'p'=>"consonant",
'q'=>"consonant",
'r'=>"consonant",
's'=>"consonant",
't'=>"consonant",
'u'=>"vowel",
'v'=>"consonant",
'w'=>"consonant",
'x'=>"consonant",
'y'=>"consonant",
'z'=>"consonant"
);
$fp=fopen($_GET['fname'],"r");
$line=fgets($fp,1024);
print "<html><h2>Original Line of Text: </h2>".$line."<p>";
/* Break string into words with explode */
$words=explode(" ",$line);
$index=0;
/* Run thru each word in array */
foreach ($words as $word)
{
$tword=trim($word);
$word=$tword;
$first=substr($word,0,1);
if ($alphabet[$first]=="vowel")
{
$pig=$word."way";
/* This word began with a vowel so we're done. */
}
else
{
$pig=rotate($word);
$word=$pig;
$first=substr($word,0,1);
/* Rotate string until we get to a vowel */
while ($alphabet[$first]=="consonant")
{
$pig=rotate($word);
$word=$pig;
$first=substr($word,0,1);
}
$pig=$word."ay";
}
$pigword[$index]=$pig;
$index=$index+1;
}
/* Now implode the words back together */
$piglatin=implode(" ",$pigword);
print "<h2>In Pig Latin: </h2>".$piglatin;
print "</html>";
?>






