Reputation:
If I have multiple numerical ranges I need to put into an array (i.e. 1-14
and 21-30
), how would I do this?
PHP has range(), but it only handles one range: http://php.net/manual/en/function.range.php
Upvotes: 0
Views: 1283
Reputation: 3424
Try with below code:
<?php
$number = range(0,14);
$num= range(21,30);
$array = array_merge($number , $num );
print_r ($array );
?>
Here is Demo
For your reference Reference Link
Upvotes: 0
Reputation: 31739
Here is the solution -
$array = array_merge(range(1, 14), range(21, 30));
Upvotes: 1
Reputation:
$alphas = array_merge(range('A', 'Z'), range('a', 'z'));
refer Way to get all alphabetic chars in an array in PHP?
Upvotes: 2