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

I am completely stuck on this...

I have no idea what I'm doing wrong...

index.php
<?php

class Render {
    public static function displayDimensions($size)
    {
     return implode("", $size[0]) . "". "X" . "" .  implode("", $size[1]);
    }
 //return displayDimensions();
}

?>

Oops, I put the answer here instead of below... It is now below.

1 Answer

//Original
return implode("", $size[0]) . "". "X" . "" .  implode("", $size[1]);

// 1. You don't need to use implode
return $size[0] . "". "X" . "" .  $size[1];

//2 You need to put a space in your "" so it will be " "
return $size[0] . " ". "X" . " " .  $size[1];

//3 The "X" needs to be "x"
return $size[0] . " ". "x" . " " .  $size[1];

// Cleaned
return $size[0] . " x " .  $size[1];

Answer:

<?php

class Render {
    public static function displayDimensions($size)
    {
     return $size[0] . " x " .  $size[1];
    }
}

?>

The Error when you preview is:

PHP Warning: implode(): Invalid arguments passed in index.php on line 6 PHP Warning: implode(): Invalid arguments passed in index.php on line 6

php.net manual says: implode ( string $glue , array $pieces ) : string

/*
It is asking for glue and an array
but you are passing it just one item out of your array when you designate [0] or [1]
*/
implode("", $size[0]);

//to implode you would pass it like this
implode("", $size);

/*
But you would get 1214 if the challenge was set up correctly. 
Since it wasn't; you will get 111222.
*/

Yep that was it. Thanks Daniel