Hi, here's a description of the problem I'm trying to solve:
write words_to_int.php, which computes and outputs the integer that corresponds to the words that the user has entered. For example, if the user enters "two four one", your program computes the integer 241 and outputs it; if the user enters "three one one two", your program computes the integer 3112 and outputs it.
You must calculate this, not just echo a 2 followed by a 4 followed by a 1.
You must calculate an integer, not create a string: your program must not use any concatenation.
So, in effect, for two four one you want to add (2 × 102) to (4 × 101) and to (1 × 100), to get 241. For three one one two, you want to add (3 × 10 to the power of 3) to (1 × 10 to the power of 2) to (1 × 10 to the power of 1) to (2 × 10 to the power of 0), to get 3112.
$position in your last loop is incorrect. You should set it to the size of the word array before the loop, and decrement it inside that loop. Also, you are adding the numbers to the original word array. Use a second one.