Excel array column double / triple / etc .. consonant generation

How would I automatically generate an array (in PHP) for AA - ZZ, etc. like AAA - ZZZ

$column_arr2= range("aa", "zz"); // NOT Working
$row_arr    = range(0,1000);
$column_arr = range("a", "z");

echo "Column2<pre>".print_r($column_arr2, true)."</pre><br />"; // prints a - z
echo "Row<pre>".print_r($row_arr, true)."</pre><br />";
echo "Column<pre>".print_r($column_arr, true)."</pre><br />";

I would like to make the number and alpha arrays dynamic as I use this for an excel document.

I would like to:

$arr = ([0] => 'a', [1] => 'b', [2] => 'c', ...
        [26] => 'aa', [27] => 'ab', [28] => 'ac', ...
        [52] => 'ba', [53] => 'bb', [54] => 'bc', ...
       )

Any ideas are welcome

+3
source share
1 answer

PHP supports incremental strings :

$array = array('A');
$current = 'A';
while ($current != 'ZZZ') {
    $array[] = ++$current;
}
+14
source

Source: https://habr.com/ru/post/1772150/


All Articles