I know I can do that using switch(), but still I wanted to know if there's any PHP function for that.
+7
A:
From one to ten:
$numbers = array("zero" => 0, "one" => 1, "two" => 2, "three" => 3, "four" => 4,
"five" => 5, "six" => 6, "seven" => 7, "eight" => 8,
"nine" => 9, "ten" => 10);
echo $numbers["nine"]; // 9
Beyond that, it gets trickier (except if you want to type out a very large list, of course.)
Pekka
2010-06-05 17:00:33
Or use an associative array `'one' => 1 ` so you don't have to search...
Felix Kling
2010-06-05 17:01:45
@Felix yeah. This was done with converting it back in mind, but good point. Editing.
Pekka
2010-06-05 17:02:31
And you excluded zero because...?
Eric
2010-06-05 17:03:18
@Eric *insert complicated mathematico-philosophical explanation here* I forgot.
Pekka
2010-06-05 17:05:02