How to print the number 1 to 10 with recursive function in PHP

1 Answer

0 votes
function recursion_print_1_to_10($a)
{
    if ($a <= 10) 
    {
        echo "$a ";
        recursion_print_1_to_10($a + 1);
    }
}

recursion_print_1_to_10(1);


/*
run:

1 2 3 4 5 6 7 8 9 10 

*/

 



answered Jun 20, 2016 by avibootz
...