Created
May 21, 2013 14:11
-
-
Save kdrdmr/5620084 to your computer and use it in GitHub Desktop.
php range_leading_zero
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
error_reporting(E_ALL); | |
ini_set('display_errors', '1'); | |
function range_leading_zero($start,$end,$size, $step=1){ | |
$arr = range($start,$end,$step); | |
$filtered_arr = array_map(function($digit) use ($size) {return sprintf("%0".$size."d", $digit);},$arr); | |
//var_export($filtered_arr); | |
return array_unique(array_merge($arr, $filtered_arr)); | |
} | |
var_export(range_leading_zero(1,12,2)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment