This forum is now read-only. Please use our new forums at discuss.codecademy.com.

Functions, Part I Forum

View Course » View Exercise

741 points
53b09c8be682c699cc412d6c2830f676?s=140&d=retro
Submitted by
indugumber
about 2 years ago

plz tell whats the problem with this..7/8

<?php
// Create an array with several elements in it,
// then sort it and print the joined elements to the screen

$thearray=array(5,7,78,5,43,4,57,8899);
sort($the
array);
print join(",",$the_array);
$thearray=array(6,8,00);
rsort($thearray);
print join(",",$thearray);
?>

this is my code and after i click submit ,it shows an error saying your reverse array should have atleast 3 elements.

can anyone tell me ...what can i do.


3 votes

permalink

The easiest way to fix this is to delete the second time you call $thearray=array(6,8,00); Since you have already called $thearray once, you do not need to call it again, but reuse it. So to fix this, try simply deleting $thearray=array(6,8,00);

Once you're done, your code should look something like this:

<html>
<p>
<?php
// Create an array with several elements in it,
// then sort it and print the joined elements to the screen
$the_array = array(0, 2, 4, 6, 8, 10, 12);
sort($the_array);
print join(", ", $the_array);
?>
</p>
<p>
<?php
// Reverse sort your array and print the joined elements to the screen
rsort($the_array);
print join(", ", $the_array);
?>
</p>
</html>

I hope this helps!

354 points
Ce287283c91c0e829fad6beb3905dd70?s=140&d=retro
Submitted by
enduffy2014
about 2 years ago