protected function alphaIndexToNumeric($alpha_index)
    {
        preg_match("~([A-Z]+)(\d)+~", $alpha_index, $match);
        $letters = range('A', 'Z');
        $letters = array_flip($letters);
        $col_index = 0;
        $strlen = strlen($match[1]);

        if($strlen== 1){
            $col_index += ($letters[$match[1]]+1);
        } elseif($strlen > 1){
            $arr = str_split($match[1]);
            $last = array_pop($arr);
            foreach($arr as $letter){
                $col_index += ($letters[$letter]+1)*26;
            }
            $col_index += ($letters[$last]+1);
        }


        return Array($col_index, $match[2]);
    }
protected function alphaIndexToNumeric($alpha_index)
    {
        preg_match("~([A-Z]+)(\d)+~", $alpha_index, $match);
        $letters = range('A', 'Z');
        $letters = array_flip($letters);
        $col_index = 0;
        $strlen = strlen($match[1]);

        if($strlen== 1){
            $col_index += ($letters[$match[1]]+1);
        } elseif($strlen > 1){
            $arr = str_split($match[1]);
            $last = array_pop($arr);
            foreach($arr as $letter){
                $col_index += ($letters[$letter]+1)*26;
            }
            $col_index += ($letters[$last]+1);
        }


        return Array($col_index, $match[2]);
    }
protected function alphaIndexToNumeric ( $ alpha_index ) { preg_match ( "~([A-Z]+)(\d)+~" , $ alpha_index , $ match ) ; $ letters = range ( 'A' , 'Z' ) ; $ letters = array_flip ( $ letters ) ; $ col_index = 0 ; $ strlen = strlen ( $ match [ 1 ] ) ; if ( $ strlen == 1 ) { $ col_index += ( $ letters [ $ match [ 1 ] ] + 1 ) ; } elseif ( $ strlen > 1 ) { $ arr = str_split ( $ match [ 1 ] ) ; $ last = array_pop ( $ arr ) ; foreach ( $ arr as $ letter ) { $ col_index += ( $ letters [ $ letter ] + 1 ) * 26 ; } $ col_index += ( $ letters [ $ last ] + 1 ) ; } return Array ( $ col_index , $ match [ 2 ] ) ; }
Converts Alpha column data to numeric indexes
@param string $alpha_index e.g. A1 or AA4
@return array (col, row)
Converts Alpha column data to numeric indexes