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 trialAmitkumar Patel
6,699 PointsReturn an collection array of house objects whose public properties roof_color OR wall_color match the passed color para
This is the error message I get:
Bummer! Make sure you are checking both the "roof_color" AND "wall_color" to see if EITHER of them match the passed $color parameter.
Can someone assist me please? I would be very thankful.
<?php
class Subdivision {
public $houses = [];
public function filterHouseColor($color) {
$lots = $house;
foreach ($this->house as $house) {
if ($house->roof_color == $color || $house->wall_color == $color) {
$lots[] = $house->lots;
}
}
return [];
}
}
?>
1 Answer
Mochammad Rezza
4,778 PointsHii Amitkumar,
let's try this code
<?php
// add code below this comment
class Subdivision
{
public $houses = [];
public $arr = [];
public function filterHouseColor($color)
{
foreach($this->houses as $house){
if($house->roof_color == $color OR $house->wall_color == $color){
$this->arr[] = $house;
}
}
return $this->arr;
}
}
?>
Amitkumar Patel
6,699 PointsHi Mochammad,
Thank you for your assistance, however I've figured it out and passed this challenge.
Thanks anyway!
Amitkumar Patel
6,699 PointsAmitkumar Patel
6,699 PointsPlease anyone? It's the final challenge 3/3 out of the collections object challenge.