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 PHP Arrays and Control Structures PHP Arrays Multidimensional Arrays

Complain

Dear Team! Why you are asking to do things in your challenges about what you had no explanations in your videos or maybe had, but in indirect way. Example:

echo "<li>" . $contacts[0]['name'];
echo " : " . $contacts[0]['email'] . "</li>\n";
echo "<li>" . $contacts[1]['name'];
echo " : " . $contacts[1]['email'] . "</li>\n";
echo "<li>" . $contacts[2]['name'];
echo " : " . $contacts[2]['email'] . "</li>\n";
echo "<li>" . $contacts[3]['name'];
echo " : " . $contacts[3]['email'] . "</li>\n";

What is that? Where was explanation about it..how to correctly output multidimensional arrays together with HTML? I had to spend an hour to find information on web and doing experiments with "Preview" button. When I wrote this.. I noticed that other people had same problems with setting output.

Maybe it sounds silly, but I am total begginer, I am very new to programming, I dont have experience in making up things about which I do not have information. If you are asking something in your challenges make sure you have some videos previosly that explains everything what might be included in challenge.

If I have to look for some additional information somewhere else on the web and not in treehouse webpage that what for I am paying subscription?..I can easy go to youyube and doing search and learning there for free..if I am paying then I need BASIC information in one place without searching arround.

I understand that programming is requiring to do a slef-search and that is what I am doing, but I am talking about some complete basic information which must be here and included in videos and examples. If you asking in challenge to output multidimensional arrays within HTML then you have to provide an example how to do it correctly before.

Thx! Sorry team and community members for complaining, but it is enough for me..it is not first challenge so far with the same issues.

6 Answers

Even in the PHP Basics course it is NOT covered how to combine HTML with PHP while concatenating. Separately yes, each is covered (combining HTML and PHP is covered, and separately how to concatenate). I took PHP Basics and I had the same great frustration as Santis because nowhere was is covered how to do this. I'm impressed that Santis found one solution in just one hour, putting "" around the HTML tags and putting in extra echos. Another more elegant solution was posted in another question about this, using {}.

Treehouse should consider revising the challenge, or adding info on how to concatenate when combining HTML and PHP.

Jennifer Nordell
seal-mask
STAFF
.a{fill-rule:evenodd;}techdegree
Jennifer Nordell
Treehouse Teacher

Hi there! I understand that it's frustrating to not be able to immediately grasp something, but multidimensional arrays are sort of a complicated topic in the beginning. In fact, Alena even addresses this at 5:39 of the video linked to this post.

"Multi-dimensional arrays can be a complicated concept to grasp. I encourage you to re-watch this video and also experiment with some multi-dimensional arrays of your own. Also make sure you check out the teacher's notes for more resources."

All the information needed to to complete the following challenge was, in fact, covered in this video. It assumes that we have a full understanding of what was covered in the previous material. But it's still up to us (the students) to take that information and apply it to a different problem.

In the video we use a multidimensional array to set up a task as such:

$list['Task 1'] = array(
    'title' => 'Laundry',
    'priority' => 2,
    'due' = >' ',
   'complete' = >
);

This is a multidimensional array or array of arrays. And there was also a hint given in the challenge about how to access an element in the array in the comments of the code. But these challenges and concepts build on each other all the time. You learn concept A, then concept B and then concept C. But you may not forget concept A altogether and expect concept C to make sense when you get to it.

Learning to program is a little like learning mathematics. It's unreasonable to think that you can learn more advanced math without having a solid foundation on the concepts before it. For instance, I would not expect a student to successfully be able to learn multiplication (without much difficulty) before they had a good grasp on addition.

My advice is to first review "normal" arrays, then review associative arrays, and then try and consolidate that information to apply it to multidimensional arrays.

I hope this helps and that you keep learning and keep coding! :sparkles:

Dear Jeniffer! I am afraid you missed my point. I am not complaining about multidimensional arrays videos or the way how they are explained. I understood quite well how they are built and what are their possibilities. What I ment is last task where I needed to output arrays using HTML unordered list elements. Did I miss some videos where it was explained how to correctly combine HTML elements with multidimensional arrays to make them display correctly?

Jennifer Nordell
seal-mask
.a{fill-rule:evenodd;}techdegree
Jennifer Nordell
Treehouse Teacher

And I believe you missed my point. The echoing out of an element of a multidimensional array element was shown at 3:46 of this video. In fact, the only difference between this line and one that was used by the challenge was that she uses the key of 'title' instead of 'name' or 'email'. Also, for the challenge you must use concatenation. But you learned string concatenation and echoing of values quite a while ago. This is what I mean about combining the total knowledge you've acquired and applying it to the challenge at hand.

At this point in the course/track echoing of a value, concatenation, accessing an element of an array, and associative arrays are not new. The only thing that is new is accessing an element from within an array inside an array. And an example of that was provided in the video.

edited for additional observation

I have noticed that you have not taken the HTML courses here. I'm wondering if the problem might lie there. HTML in conjunction with PHP was covered in this course. Is it possible you missed this one?

Ok, you don't understand my point..and I don't understand yours. So let's just leave it.. I solved the challenge anyway and that is more important.

Have a great day and Happy New Year!

Natalie Feibish
Natalie Feibish
2,599 Points

I just had no idea what was being asked for. I took PHP, HTML, have been doing it forever and I understand multi-dimensional arrays, but could not figure out what I was supposed to do because the challenge was worded poorly. Are we trying to completely recreate that list? Exactly? Or just output the same info without using the list? It's just completely out of context of what we had been doing, so the actual goal threw me. Based on what I"m seeing here the goal is to exactly recreate it which seems just funky as crap since that's what loop statements are for. But again, I've worked with PHP before so... yeah, no idea what you wanted. Reconsider this task.

the description of the challenge needs to be adequate to clearly suggest a solution, and it does not currently do that.

In development these days, people often write the tests first, because that can help to plan out how to do something. The ambiguity in the description for this challenge and how to use multidimensional arrays is enough that it does not immediately suggest the solution that is acceptable to the PHP interpreter.

a huge part of the confusion around this problem, i think, is that the first task doesnt make clear that we want to do "y" by the end of the three tasks, but for this step we want you to do "x". and "x" isnt particularly clear, nor is it obvious that one can declare that $stuff = array(array(...)); in one statement. The video declares independent array variables first, and then collects them using another array declaration.

Aaron Bartleson
Aaron Bartleson
14,581 Points

I am very frustrated by this as well. I have spent a couple hours on this and on task 3 many times I get "Oops task one is no longer passing" It is a very frustrating glitch.

I would like some help because I have copied what was up above and done everything imaginable and I still can't get to pass task 3. This is by far the worst challenge with the least explanation and highest Glitch I have seen. I have watched the video 10+ times and seem not to know what I am supposed to do!

my pic

The code in the question lost the closing: echo "</ul>\n";