字母数组在第7个索引(“h”)后不起作用

时间:2014-04-07 14:08:43

标签: php alphabet

我有以下字母数组

$_CharCodes = array(
                    "A" => 01, "B" => 02, "C" => 03, "D" => 04, "E" => 05, "F" => 06, 
                    "G" => 07, "H" => 08, "I" => 09, "J" => 10, "K" => 11, "L" => 12, 
                    "M" => 13, "N" => 14, "O" => 15, "P" => 16, "Q" => 17, "R" => 18, 
                    "S" => 19, "T" => 20, "U" => 21, "V" => 22, "W" => 23, "X" => 24, 
                    "Y" => 25,  "Z" => 26, 
                    "SUPC" => 27, "SUBC" => 28, "SUPD" => 29, "SUBD" => 30, "DOT" => 31, "DASH" => 32                        
                    );

当我使用索引测试数组的值时(是的,它是字母),

echo 'a is: '.$this->_CharCodes[strtoupper("a")]."<br/>";
    echo 'b is: '.$this->_CharCodes[strtoupper("b")]."<br/>";
    echo 'c is: '.$this->_CharCodes[strtoupper("c")]."<br/>";
    echo 'd is: '.$this->_CharCodes[strtoupper("d")]."<br/>";
    echo 'e is: '.$this->_CharCodes[strtoupper("e")]."<br/>";
    echo 'f is: '.$this->_CharCodes[strtoupper("f")]."<br/>";
    echo 'g is: '.$this->_CharCodes[strtoupper("g")]."<br/>";
    echo 'h is: '.$this->_CharCodes[strtoupper("h")]."<br/>";
    echo 'i is: '.$this->_CharCodes[strtoupper("i")]."<br/>";
    echo 'j is: '.$this->_CharCodes[strtoupper("j")]."<br/>";
    echo 'k is: '.$this->_CharCodes[strtoupper("k")]."<br/>";
    echo 'l is: '.$this->_CharCodes[strtoupper("l")]."<br/>";
    echo 'm is: '.$this->_CharCodes[strtoupper("m")]."<br/>";
    echo 'n is: '.$this->_CharCodes[strtoupper("n")]."<br/>";
    echo 'o is: '.$this->_CharCodes[strtoupper("o")]."<br/>";
    echo 'p is: '.$this->_CharCodes[strtoupper("p")]."<br/>";
    echo 'q is: '.$this->_CharCodes[strtoupper("q")]."<br/>";
    echo 'r is: '.$this->_CharCodes[strtoupper("r")]."<br/>";
    echo 's is: '.$this->_CharCodes[strtoupper("s")]."<br/>";
    echo 't is: '.$this->_CharCodes[strtoupper("t")]."<br/>";
    echo 'u is: '.$this->_CharCodes[strtoupper("u")]."<br/>";
    echo 'v is: '.$this->_CharCodes[strtoupper("v")]."<br/>";
    echo 'w is: '.$this->_CharCodes[strtoupper("w")]."<br/>";
    echo 'x is: '.$this->_CharCodes[strtoupper("x")]."<br/>";
    echo 'y is: '.$this->_CharCodes[strtoupper("y")]."<br/>";
    echo 'z is: '.$this->_CharCodes[strtoupper("z")]."<br/>";

返回如下:

a is: 1
b is: 2
c is: 3
d is: 4
e is: 5
f is: 6
g is: 7
h is: 0
i is: 0
j is: 10
k is: 11
l is: 12
m is: 13
n is: 14
o is: 15
p is: 16
q is: 17
r is: 18
s is: 19
t is: 20
u is: 21
v is: 22
w is: 23
x is: 24
y is: 25
z is: 26

为什么它为h&amp;返回0我?

1 个答案:

答案 0 :(得分:5)

由于领先01

090是八进制文字。 0809是无效的八进制文字(因为您没有标记任何语言,我不知道您的翻译在这种情况下如何进行)。

尝试删除前导零。

((旧:“所有月份都在工作,除了octobre和septembre” - 问题。)