Such a script:

1 $stri = ''; 2 for ($e = 1; $e <= 3; $e++) { 3 for ($p = 0; $p < $e; $p++) { 4 $stri = $stri . $e; 5 } 6 echo $stri.'<br>'; 7 $stri = ''; } 

Please explain why, when executing line 7 on the line, the result is displayed on the screen:

one

22

333

But if you remove the code on line 7, it displays:

one

122

122333

What effect does the code on line 7 have? After all, before that, on line 6 there is already an echo ...

  • It clears the variable and at the next execution of the loop it will be empty at the beginning. with the same success, this line could be inserted between 2 and 3 and then at the same time remove 1 - Mike
  • Yes, it is clearer even now. Thank. The issue is resolved. - Beginner

0