Error showing values in a loop

1

I am doing a program that makes successive numbers from 10 to 1 pairs, odd and multiples of five, but does not throw anything at me and I do not understand how it causes the result to look down as columns:

10    2      3       1
9     4      5       5
8     6             10
7     8      11     15

This is the code:

<?php
$sucesivo=11-$i;
$pares=$i * 2;
$impares=$i * 2 - 1;
$quintos=$i * 5 -5;

for($i=1; $i<=10; $i++){

  echo $sucesivo,$pares,$impares,$quintos;

}

?>
    
asked by wdwd 05.10.2017 в 08:44
source

1 answer

1

Solved.

$i does not exist when you are using it on the first line of your code.

<?php
$i=1;
$sucesivo=11-$i;
$pares=$i * 2;
$impares=$i * 2 - 1;
$quintos=$i * 5 -5;

for($i; $i<=10; $i++){

  echo $sucesivo,$pares,$impares,$quintos;

}

?>

In fact, the same thing happened to you in a question that I solved yesterday: Link

Try to understand the solution and find the error for yourself before asking each exercise that you have to perform in this forum.

    
answered by 05.10.2017 / 09:07
source