A quick way to set Excel column headers to an array in PHP -


this question has answer here:

i using array selecting column in excel. right need a through cz, might need expand larger set in future. i'm hoping has faster or better way i'm doing this.

here i'm doing now:

$columnarray2 = array('a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'); $columnarray = array(); for($x = 0 ; $x <= 25 ; $x++) {     $columnarray[] = $columnarray2[$x]; } for($x = 0 ; $x <= 4 ; $x++) {     for($y = 0 ; $y <= 25 ; $y++)     {         $columnarray[] = $columnarray2[$x].$columnarray2[$y];     } } 

this gives me array 155 values going a ez.

is there better way accomplish this?

you realise php supports perl-style incrementing of characters, means can do:

$startcolumn = 'a'; $endcolumn = 'cz'; ++$endcolumn;  $columnarray = []; for($column = $startcolumn; $column != $endcolumn; ++$column) {     $columnarray[] = $column; } 

the thing watch out end condition cannot use < or >, increment actual end, , use !=


Comments

Popular posts from this blog

PHP and MySQL WP -

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

go - golang pprof for c library code -