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

Nick Tsamis
PLUS
Nick Tsamis
Courses Plus Student 4,267 Points

i want some help with this challenge task

how i can fixed this?

index.php
<?php

class Render {



   public static function displayDimensions($size){

   $size = array('lenght', 'width');

   return implode(" x ", $size);

   }

}

?>
Mark Giles
Mark Giles
7,049 Points

You are setting the values in the array to the strings 'lenght' and 'width' which produces an array of the two strings (words). I believe what you want is to pass the function dimensions and have it display the numbers with an x in between them. If this is case you would do something like this:

 1 <?php
  2
  3 class Render {
  4         public static function displayDimensions($size) {
  5                 return implode(" x ", $size);
  6         }
  7 }
  8
  9 $size = array(4, 5);
 10 $ren = new Render();
 11  echo $ren->displayDimensions($size);
 12
 13 ?>

The function is able to take the dimension values as an array, implode them by adding the " x " between them, and return the desired display string.

2 Answers

Nish Patel
Nish Patel
1,103 Points

This should help you:

class Render {
  public static function displayDimensions($size)
  {
    return $size[0] . " x " . $size[1];
  } 
}
?>
Mark Giles
Mark Giles
7,049 Points

This is correct in regard to the code challenge. The challenge is specifically looking for the $size array with specified index values ($size[0] and $size[1]). To use implode in your own project, you could use the method I show in a separate comment.

Nick Tsamis
Nick Tsamis
Courses Plus Student 4,267 Points

yes i made this at working thank you very much!!Nish:)