0

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

1
  • So use two range() one array_merge() Commented May 8, 2015 at 5:44

3 Answers 3

2
$alphas = array_merge(range('A', 'Z'), range('a', 'z'));

refer Way to get all alphabetic chars in an array in PHP?

Sign up to request clarification or add additional context in comments.

Comments

1

Here is the solution -

$array = array_merge(range(1, 14), range(21, 30));

DEMO

Comments

0

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.