Welcome to the Treehouse Community
The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Alexisca hall
23,683 PointsReturn an collection array of house objects whose public properties roof_color OR wall_color match the passed color para
Return an collection array of house objects whose public properties roof_color OR wall_color match the passed color parameter. Note: The local houses array contains an array of House objects, each of which has a public property for "roof_color" and "wall_color".
<?php
class Subdivision {
public $houses = []; // Same thing as array()
public function filterHouseColor($color) {
$lots = []; // just a temporary array
// Looks like this is where you got lost
// In order to access the $houses array, you need to do $this->houses because $houses is a property on Subdivision
// This foreach loop loops through the $houses array
// So each cycle, $house contains a $house object found in $houses
foreach ($this->houses as $house) {
// Remember: you can only access $roof_color and $wall_color from the $house object
if ($house->roof_color === $color || $house->wall_color === $color) {
$lots[] = $house->lot; // Here, we append the value of each $house's $lot property to that temporary array up there named $lots
}
}
return $lots; // Finally, we return $lots
}
}
?>
1 Answer

Mikkel Rasmussen
31,769 PointsYou just need to change your append value in your if statement from $house->lot to just $house.
Caleb Kleveter
Treehouse Moderator 37,862 PointsCaleb Kleveter
Treehouse Moderator 37,862 PointsWhat is the problem you are running into? I am not very fluent in PHP so I can't help, but this will help others trying to solve your problem.