Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

PHP

hints on a quiz question....

This is a quiz question for an online course I am taking...

Write a PHP function called printPattern that prints out the following star pattern using no more than four (4) lines of code.

// *

// **

// ***

// ****

// *****

I don't want the answer... but hints so I can solve it myself... (I am barely starting coding btw).

So far, I have studied a little of html, css, and PHP. They want me to write this code in php. I have used variables; statements such as "foreach" "for" "isset" "if/else." Also I can do a little bit of arrays.

Basically, I want you guys to help me by maybe guiding me as to what would be the easiest way to do this (don't do it for me, maybe tell me what kind of commands, variables or statements I can use solve the problem. Thanks.

1 Answer

Ken Alger
STAFF
Ken Alger
Treehouse Teacher

Jose;

There are probably a multitude of ways to achieve those results. I would venture to guess that since you are just starting PHP the solution would be based around some of the more basic concepts like for statements and string concatenation. At least that is the way in which I was able to produce those results in four lines of code.

As you work through your project, utilize the Markdown Cheatsheet when posting your code.

Best of luck on your project.

Ken