PHP, how to create an array from 1 to 365 without looping or brute force typing -



PHP, how to create an array from 1 to 365 without looping or brute force typing -

matlab has simple syntax type myarray = [1:365] , create array integers 1 365. how done in php? know php's arrays more matlab struct types. there keys-value pairs.

easy. utilize range:

// create range 1 365. $myarray = range(1,365); // dump line array debugging. echo '<pre>'; print_r($myarray); echo '</pre>';

and output of print_r dump be:

array ( [0] => 1 [1] => 2 [2] => 3 [3] => 4 [4] => 5 [5] => 6 [6] => 7 [7] => 8 [8] => 9 [9] => 10 [10] => 11 [11] => 12 [12] => 13 [13] => 14 [14] => 15 [15] => 16 [16] => 17 [17] => 18 [18] => 19 [19] => 20 [20] => 21 [21] => 22 [22] => 23 [23] => 24 etc…

php arrays

Comments

Popular posts from this blog

php - Android app custom user registration and login with cookie using facebook sdk -

django - Access session in user model .save() -

php - .htaccess Multiple Rewrite Rules / Prioritizing -