brenlei.com

PHP tutorials

Question:

I'm creating a series of arrays for a calender. I've got the month calender down pat, but is there an easy way to create an array for the days without having to type in 31 elements individually?.

Answer:

Use the range function. The example below will create an array with elements valued from 1 to 31.

<?php
$days = range(1, 31);
?>

PHP Reference Manual

range - Create an array based on a range

Comments or questions relating to this article have been disabled. They will be back soon.