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 trialEric C
7,998 Pointsmy output for the exercise functions correctly but I still have \n\n\n\n\n\n\ echoing in the middle
0 = Laundry 1 = Dishes 2 = Dust 3 = Vacuum 4 = Make Dinner 5 = Clean Out Fridge \n\n\n\n\n\n Title Priority Due Date Complete Laundry 2 06/09/2016 No Dishes 2 No Dust 3 No Vacuum 1 06/09/2016 No Make Dinner 1 No Clean Out Fridge 2 07/30/2016 Yes
from
<?php
include 'list.php';
foreach ($list as $key => $item) { echo $key . ' = ' . $item['title'] . "<br />\n"; } echo '<table>'; echo '<tr>'; echo '<th>Title</th>'; echo '<th>Priority</th>'; echo '<th>Due Date</th>'; echo '<th>Complete</th>'; echo '</tr>';
foreach ($list as $item) { echo '<tr>'; echo '<td>' . $item['title'] . "</td>\n"; echo '<td>' . $item['priority'] . "</td>\n"; echo '<td>' . $item['due'] . "</td>\n"; echo '<td>'; if ($item['complete']) { echo 'Yes'; } else { echo 'No'; } echo '</td>\n'; echo '<tr>'; }
//var_dump($list);
//echo $list[0]['title']; ?>
1 Answer
Mark Truitt
17,230 PointsHi Eric,
What specifically is your question? As it is a bit hard to figure out what it is your are asking in this. Please also review the Markdown Cheatsheet for adding code. It helps the readability and others to answer you easier and quicker.
Mark
Eric C
7,998 PointsEric C
7,998 PointsSo, my question is, why am I getting bunch of \n;s in my output? when I bring up the browser from workspaces, I get a bunch of them. I think I have the code matching the teacher exactly, but the html is pumping out \n's and I don't understand why or how to get rid of them
HERE IS THE OUTPUT
```0 = Laundry 1 = Dishes 2 = Dust 3 = Vacuum 4 = Make Dinner 5 = Clean Out Fridge \n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n Title Priority Due Date Complete Laundry 2 06/09/2016 No Dishes 2 No Dust 3 No Vacuum 1 06/09/2016 No Make Dinner 1 No Clean Out Fridge 2 07/30/2016 Yes
HERE IS THE CODE
<?php
include 'list.php';
foreach ($list as $key => $item) { echo $key . ' = ' . $item['title'] . "<br />\n"; }
echo '<table>'; echo '<tr>'; echo '<th>Title</th>'; echo '<th>Priority</th>'; echo '<th>Due Date</th>'; echo '<th>Complete</th>'; echo '</tr>';
foreach ($list as $item) { echo '<tr>'; echo '<td>' . $item['title'] . '</td>\n'; echo '<td>' . $item['priority'] . '</td>\n'; echo '<td>' . $item['due'] . '</td>\n'; echo '<td>'; if ($item['complete']) { echo 'Yes'; } else { echo 'No'; } echo '</td>\n'; echo '<tr>'; }
//var_dump($list);
//echo $list[0]['title']; ?>
Mark Truitt
17,230 PointsMark Truitt
17,230 PointsHi Eric,
You were close using the ``` in a row. You need to do ```php (three in a row) then hit enter then <?php press enter again and paste your code for it to format correctly.
Looking at your code you are close. As you have
And it needs to be
You need to use a double quote vs a single. Otherwise it prints the \n directly to the screen vs interpreting it as an escaped character.