Created
July 31, 2021 08:25
-
-
Save yokada/76410d22c014ab09f7ce7ff0a8a28e77 to your computer and use it in GitHub Desktop.
Revisions
-
yokada created this gist
Jul 31, 2021 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,16 @@ <?php /** * convert column name to index number. * * @param string $col 'Z', 'AA', 'ZAA' */ function col2idx($col = 'AZ') { $idx = 0; $k = count(range('A', 'Z')); $cols = array_reverse(str_split($cols)); foreach ($cols as $i => $c) { $idx += count(range('A', $c)) * pow($k, $i); } return $idx; }