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 the Recipe Static

Return the $size array as a string?

I don't understand what they want me to do. I tried it with return $size, but that returns the array itself. So i made a foreach loop and append it to a var named $output.. and then return $output.


class Render {
    public static function displayDimensions($size){
      return $size;


1 Answer

The task is looking for the string "length x width". For this you can specify the individual elements concatenated with x as

 public static function displayDimensions($size){
      return $size[0] . ' x ' . $size[1];

Who the heck makes such things separate? If you have a dimension, you prob make it something like ['10cm x 20cm','5cm x 10cm']. If you make it something like ['10cm','50cm','14cm'] those are not dimensions, just random values inside an array. I was expecting something like ['10cm x 20cm']... Either they fix these arrays or they show how the array looks like.