Need help with simple for loop new to PHP and forum

I need to figure out how to make 5 rows of * and only use one for loop it has been driving me nuts all week any help is greatly appreciated because I have tried so many different ways. I am trying to create this but with only one for loop in php

Hello. This is one simple but yet effective codeish, hope you find it helpful.


$addingvar = '*'; // our pattern
$var = ''; // just to call variable

foreach(range(1,5) as $value) {
	$var .= $addingvar;
	echo $var . '<br />';

What I did there was added two variables (one is our pattern, in this case * while another one is variable that will recieve pattern each time loop repeats).
foreach function is something you should already know of, if not check its manual . I added simple range function instead of doing array(1,2,3,4,5). If you have any other questions let me know.

Best regards, Dino :slight_smile: