Question

I have following alphabet array

$_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                        
                    );

when I am testing the values of array by using index (yes, it is letter),

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/>";

it is returns like following:

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

why it returns 0 for h & i?

Was it helpful?

Solution

01 thru 09 are octal literals due to the leading 0. 08 and 09 are invalid octal literals (and as you haven't tagged any language, I do not know how your interpreter proceeds in this case).

Try removing the leading zeros.

((The old: "All months are working except octobre and septembre"-problem.))

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top