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 Object-Oriented PHP Basics Building a Collection Collection Objects

Kelvin Vockins
Kelvin Vockins
3,071 Points

Hi having problems with the code challenge

Think I am close but will see

Rohald van Merode
seal-mask
.a{fill-rule:evenodd;}techdegree
Rohald van Merode
Treehouse Staff

Hey Kelvin Vockins 👋

I hope you've been able to pass this challenge since creating this post, if not feel free to share your code and we'll be more than happy to assist 🙂

Kelvin Vockins
Kelvin Vockins
3,071 Points
// add code below this comment
class Subdivision 
{
  public $houses;
  public function filterHouseColor($color = null)
  {
    $localHouses = array();
    foreach($this->houses as $house)
    {
      if($house->roof_color == $color || $house->wall_color == $color)
      {
        $localHouses[] = $house;
      }
      echo "<pre>";
      var_dump($house);
      echo "<pre>";
    }

    return $localHouses;
  }
}

$h = new Subdivision();

?>```

2 Answers

Brian Jensen
seal-mask
STAFF
.a{fill-rule:evenodd;}techdegree seal-36
Brian Jensen
Treehouse Staff

Hiya Kelvin Vockins! :wave:

Thank you for sharing your code! It looks great and is actually passing all 3 stages of the challenge for me. What is happening when you try using it in the challenge?

Based on the code block you shared, there are only a couple possible issues that I can see. The stray closing PHP tag and the 3 back-ticks at the bottom, and the missing opening PHP tag at the top.

I imagine the 3 back-ticks are just from formatting your message when you posted here. With the closing tag ?>, I would say double check that it wasn't accidentally doubled up with the closing tag that is automatically provided for you in the 1st stage of the challenge. For the opening tag <?php that is also automatically included in the 1st stage, I would say to double check that it wasn't accidentally deleted.

Let us know if you are still running into any issues! :thumbsup: