| Conditions | 4 |
| Paths | 5 |
| Total Lines | 14 |
| Code Lines | 8 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 23 | public static function titleToNumber2(string $title): int |
||
| 24 | { |
||
| 25 | if (empty($title)) { |
||
| 26 | return 0; |
||
| 27 | } |
||
| 28 | [$ans, $map] = [0, []]; |
||
| 29 | for ($i = 1; $i < 27; $i++) { |
||
| 30 | $map[strtoupper(chr($i + 65 - 1))] = $i; |
||
| 31 | } |
||
| 32 | for ($i = 0, $n = strlen($title); $i < $n; $i++) { |
||
| 33 | $ans = $ans * 26 + $map[strtoupper($title[$i])]; |
||
| 34 | } |
||
| 35 | |||
| 36 | return $ans; |
||
| 37 | } |
||
| 39 |