Been trying this for a while and even searched the net but didn't get what I am doing wrong, I got the function but it's just that it won't print the two first digits that is supposed to be 0 and 1 followed by what's get printed by my code.
<?php
//Create a function
function fibonacci($nr){
//Make an array to hold the numbers
$prev = array(0, 1);
//Make the loop
for ($i = 0; $i < $nr; $i++){
//Number is the sum of the previous two
$num = $prev[0]+ $prev[1];
//Echo out the number
echo $num . '<br>';
//The sum of the two numbers is put in the second array
$prev[0] = $prev[1];
//The second array holds the new value
$prev[1] = $num;
}
}
//Enter how many numbers you would like to generate
fibonacci(15);
?>
The two starting numbers is there in the array (0, 1), what am I missing?