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 trialYousef Sayer
Front End Web Development Techdegree Student 5,190 PointsI don't understand the purpose of $status variable.
$status = 'all';
$order = array(); $field = 'priority';
if($status == 'all'){ $order = array_keys($list); }else { foreach ($list as $key => $item) { if ($item['complete'] == $status) { $order[] = $key; } } }
/////////////////// $status variable is string and $item['complete'] is boolean. How the compare here will work!! They are not same type!! if ($item['complete'] ===$status) { $order[] = $key; }
2 Answers
Corey Montgomery
18,468 PointsApparently from what I can tell and looking at other peoples questions on this topic, it is an error in the video. In this post: https://teamtreehouse.com/community/please-status-true-issue it appears the solution was found by a couple other people already.
Waqar Mohammad provides the solution which is to change the condition of the first if to ($status === "all") instead of ($status == "all").
The reason for this is further explained by Alexandre Babeanu who explains the difference between == and === in php when comparing boolean and strings. He states "When status is set to true then status it is set as a boolean. when comparing a boolean to a string with == php will look either for an empty string (false) or for not an empty string (true)."
Their answers should provide you with the information you seek and deserve all credit.
Yousef Sayer
Front End Web Development Techdegree Student 5,190 PointsAny help