need help with simple for loop new to PHP and forum

General discussions related to php

Moderators: macek, egami, gesf

Post Reply
php9
New php-forum User
New php-forum User
Posts: 13
Joined: Fri Feb 22, 2013 2:20 am

Re: need help with simple for loop new to PHP and forum

Post by php9 » Fri Feb 22, 2013 2:41 am

That's pretty easy if you know which function to use. In order to do it in only one loop, you'll need to use the str_repeat() function. Here's the code:

Code: Select all

for($i=1; $i<6; $i++)
{
    echo str_repeat('*', $i) . "<br />";
}
This will show the desired output on a page.

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest