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.

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!