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

Ethan Thompson
Ethan Thompson
1,081 Points

Why is the editor not recognizing my conditional?

After looking through other student's code examples and mistakes, I believe I've confirmed that my conditional is correct. I think something is wrong with the editor because it keeps telling me to check both properties, which I'm already doing. Or maybe I've missed a small, but critical detail? Any help would be appreciated.

index.php
<?php

// add code below this comment

class Subdivision {

    public $houses = array();

    public function filterHouseColor($color) {
      $output = array();
        foreach ($this-houses as $house) {
           if ($house->roof_color === $color || $house->wall_color === $color) {
              $output[] = $house;
           }
        }
      return $output;
    }

}

?>

1 Answer

Hi, you are missing a greater than symbol in your foreach condition: $this-houses. it should be like $this->houses.

good luck coding ;)

Ethan Thompson
Ethan Thompson
1,081 Points

Ha! I knew I probably missed something very basic. I guess I've been staring at my screen too long. Thanks, Hossein!