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 trialKeith Miller
2,310 PointsI am completely stuck on this...
I have no idea what I'm doing wrong...
<?php
class Render {
public static function displayDimensions($size)
{
return implode("", $size[0]) . "". "X" . "" . implode("", $size[1]);
}
//return displayDimensions();
}
?>
1 Answer
Daniel Baker
15,369 Points//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.
*/
Keith Miller
2,310 PointsYep that was it. Thanks Daniel
Daniel Baker
15,369 PointsDaniel Baker
15,369 PointsOops, I put the answer here instead of below... It is now below.