Q:

Write a PHP program to create a range like the following array

0

Write a PHP program to create a range like the following array.

Array
(
[20] => 2
[21] => 3
[22] => 4
[23] => 5
[24] => 6
[25] => 7
)

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

<?php
print_r(array_combine(range(20, 25),range(2,7)));
?>

Sample Output:

Array                                                       
(                                                           
    [20] => 2                                               
    [21] => 3                                               
    [22] => 4                                               
    [23] => 5                                               
    [24] => 6                                               
    [25] => 7                                               
)

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now