如何为AA-ZZ等自动生成数组(在PHP中),如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 />";
我希望将数字和alpha数组设置为动态,因为我将它用于excel文档。
我想要的是:
$arr = ([0] => 'a', [1] => 'b', [2] => 'c', ...
[26] => 'aa', [27] => 'ab', [28] => 'ac', ...
[52] => 'ba', [53] => 'bb', [54] => 'bc', ...
)
欢迎任何想法
答案 0 :(得分:14)
PHP supports incrementing strings:
$array = array('A');
$current = 'A';
while ($current != 'ZZZ') {
$array[] = ++$current;
}