2012-02-09 78 views
0

我想讓一個數組分配一個整數(十進制)值到從字符串中檢索到的'回車'鍵。但它不起作用還有。試圖'\ R'=> 149'\ n \ R'=> 149'\ n'=> 149'\ r \ n'=> 149使用數組來分配一個整數值到一個輸入(中斷等)

這是目前陣:

$numbers = array(// Epic long array // 
'a' => 0, 'b' => 1, 'c' => 2, 'd' => 3, 'e' => 4, 
'f' => 5, 'g' => 6, 'h' => 7, 'i' => 8, 'j' => 9, 
'k' => 10, 'l' => 11, 'm' => 12, 'n' => 13, 'o' => 14, 
'p' => 15, 'q' => 16, 'r' => 17, 's' => 18, 't' => 19, 
'u' => 20, 'v' => 21, 'w' => 22, 'x' => 23, 'y' => 24, 
'z' => 25, 'A' => 26, 'B' => 27, 'C' => 28, 'D' => 29, 
'E' => 30, 'F' => 31, 'G' => 32, 'H' => 33, 'I' => 34, 
'J' => 35, 'K' => 36, 'L' => 37, 'M' => 38, 'N' => 39, 
'O' => 40, 'P' => 41, 'Q' => 42, 'R' => 43, 'S' => 44, 
'T' => 45, 'U' => 46, 'V' => 47, 'W' => 48, 'X' => 49, 
'Y' => 50, 'Z' => 51, 0 => 52, 1 => 53, 2 => 54, 
3 => 55, 4 => 56, 5 => 57, 6 => 58, 7 => 59, 
8 => 60, 9 => 61, ' ' => 62, '.' => 63, ',' => 64, 
';' => 65, ':' => 66, '\'' => 67, '"' => 68, '[' => 69, 
']' => 70, '{' => 71, '}' => 72, '(' => 73, ')' => 74, 
'+' => 75, '-' => 76, '@' => 77, '#' => 78, '$' => 79, 
'%' => 80, '^' => 81, '&' => 82, '*' => 83, '!' => 84, 
'?' => 85, '<' => 86, '>' => 87, '/' => 88, '\\' => 89, 
'|' => 90, '=' => 91, '`' => 92, '~' => 93, '€' => 94, 
'«' => 95, '»' => 96, '¥' => 97, '£' => 98, 'é' => 99, 
'è' => 100, 'ê' => 101, 'ë' => 102, 'ó' => 103, 'ò' => 104, 
'ö' => 105, 'ô' => 106, 'õ' => 107, 'á' => 108, 'à' => 109, 
'â' => 110, 'ä' => 111, 'ã' => 112, 'í' => 113, 'ì' => 114, 
'ï' => 115, 'î' => 116, 'ú' => 117, 'ù' => 118, 'û' => 119, 
'ü' => 120, 'ç' => 121, '©' => 122, '™' => 123, 'ø' => 124, 
'É' => 125, 'È' => 126, 'Ë' => 127, 'Ó' => 128, 'Ò' => 129, 
'Ö' => 130, 'Ô' => 131, 'Õ' => 132, 'Á' => 133, 'À' => 134, 
'Â' => 135, 'Ä' => 136, 'Ã' => 137, 'Í' => 138, 'Ì' => 139, 
'Ï' => 140, 'Î' => 141, 'Ú' => 142, 'Ù' => 143, 'Û' => 144, 
'Ü' => 145, 'Ç' => 146, 'Ø' => 147, '÷' => 148, '\r' => 149 
); 
+3

你沒有聽說過['chr'](http://www.php.net/manual/en/function.chr.php)和['odr'](http://php.net/ manual/en/function.odr.php) – diEcho 2012-02-09 17:49:13

+1

好點。你想要做什麼?你能告訴我們更多的代碼,因爲它可以幫助我們提出更好的解決方案:) – 2012-02-09 17:52:23

+0

這只是一個轉換表,我能夠輕鬆編輯字符而不是ASCII表。這樣就更容易調試了,這很重要,因爲它是一個使用我們自己的算法創建加密和解密系統的項目 – Joriktm 2012-02-09 18:00:33

回答

1

嘗試在雙引號包裝轉義字符,即:

"\n" 
+0

這樣做,它會工作 – 2012-02-09 18:00:44

+0

謝謝!那個釘了它! 儘管我必須添加兩個鍵(「\ n」和「\ r」)才能使其完全工作。 – Joriktm 2012-02-09 18:08:03

+0

如果他的回答幫助您解決了問題,請將其標記爲已接受 – Laxman13 2012-02-09 18:33:34

相關問題