Alright, well i just got into php tonight, and I say it's been rather fun. I've taken a programming course before, and I understand a lot of programming logic, so I didn't start off as a complete idiot.
Now I've started on my first script, which translates english into this new language, Lumish, which is just scrambled characters, but it's not all random. Each character is switched to another character already pre-set. So far, I've got 90% of the script working, because I've set in test echoes, which prove that the for statement works.
Ah, but I'm getting ahead of myself. I should explain how I constructed it first. Well, I made a form [which everyone probably knows how to do], and it send the information and stores it in the string $text. I also read the length of it, and store it in the variable $length.
Both these variables have been tested, and work. Now, I get down to my for loop. I set it up so that it goes through each individual character and I have 26 if/elseif statements [which will be doubled when I finish] that check the character, and then change it, BUT it only works one time. It goes through the for loop and only does the effects to the first character, even though it's supposed to do it to all the characters. Actually, most of the time it doesn't even do anything. I have no idea why it won't work, and thus I've come here to ask help. I'm sorry if it's a little long to read. Can someone please tell me what I'm doing wrong?
Here is the actual code. If you need an example of it, just tell me.
<html>
<body>
<?php
//Variables
$text = $_POST['txt'];
$length = strlen ($text)-1;
echo "English: $text <br />";
//For statement that changes each individual character in the text one at a time until it reaches the last character.
for ($i=0; $i<=$length; $i++) {
if ($text{i}=="a") {
$text{i}="e";
}
elseif ($text{i}=="e") {
$text{i}="a";
}
elseif ($text{i}=="i") {
$text{i}="o";
}
elseif ($text{i}=="o"){
$text{i}="u";
}
elseif ($text{i}=="u") {
$text{i}="i";
}
elseif ($text{i}=="b") {
$text{i}="c";
}
elseif ($text{i}=="c") {
$text{i}="d";
}
elseif ($text{i}=="d") {
$text{i}="f";
}
elseif ($text{i}=="f") {
$text{i}="b";
}
elseif ($text{i}=="g") {
$text{i}="h";
}
elseif ($text{i}=="h") {
$text{i}="g";
}
elseif ($text{i}=="j") {
$text{i}="k";
}
elseif ($text{i}=="k") {
$text{i}="j";
}
elseif ($text{i}=="l") {
$text{i}="m";
}
elseif ($text{i}=="m") {
$text{i}="l";
}
elseif ($text{i}=="n") {
$text{i}="p";
}
elseif ($text{i}=="p") {
$text{i}="n";
}
elseif ($text{i}=="q") {
$text{i}="r";
}
elseif ($text{i}=="r") {
$text{i}="q";
}
elseif ($text{i}=="s") {
$text{i}="v";
}
elseif ($text{i}=="t") {
$text{i}="s";
}
elseif ($text{i}=="v") {
$text{i}="t";
}
elseif ($text{i}=="w") {
$text{i}="x";
}
elseif ($text{i}=="x") {
$text{i}="y";
}
elseif ($text{i}=="y") {
$text{i}="z";
}
elseif ($text{i}=="z") {
$text{i}="w";
}
}
echo "Lumish: " . $text . "<br /><br />";
echo "Well there you have it. That is what it would sound like in Lumish. Pretty neat, huh? Though this isn't the end of it! Expect this translator to be updated. Future updates include:" . "<br />";
echo "- An option to translate Lumish to English." . "<br />";
echo "- The actual character maps of what it would look like written in Lumish." . "<br />";
echo "- Maybe even translate entire websites into Lumish." . "<br />";
echo "- Maybe some more grammar changes." . "<br />";
echo "- A smaller pop-up sized window for convienence.";
?>
</body>
</html>