Skip to content

Instantly share code, notes, and snippets.

@shelane
Created July 7, 2023 03:29
Show Gist options
  • Save shelane/9779cbf23cc7df7b5b65a8d008710faa to your computer and use it in GitHub Desktop.
Save shelane/9779cbf23cc7df7b5b65a8d008710faa to your computer and use it in GitHub Desktop.
replace display day, month, etc with range function
<?php
// This is leading zeros:
$n = 10; // The desired end number
$numbers = range(1, $n);
$numbersWithLeadingZeros = array_map(function ($number) {
return sprintf('%02d', $number);
}, $numbers);
// Just a range:
$numbers = range(1, $n);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment