php - Add html element between elements in sequence generated from range -
newb here trying write simple function generate range of numbers (or letters) comma separated gennumeric(1,10,3);
homecoming 1, 4, 7, 10
instead of 14710
code:
function gennumeric($numstart, $numend, $numstep){ foreach (range($numstart, $numend, $numstep) $numsequence){ echo $numsequence; } }
no need loop in case, can utilize implode()
outright:
function gennumeric($numstart, $numend, $numstep){ echo implode(', ', range($numstart, $numend, $numstep)); } gennumeric(1, 10, 3);
or returned value:
function gennumeric($numstart, $numend, $numstep){ homecoming implode(', ', range($numstart, $numend, $numstep)); } echo gennumeric(1, 10, 3);
php html arrays range sequence
No comments:
Post a Comment