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

Functions, Part I Forum

View Course » View Exercise

791 points
6e50938c8dd8b84872eb7734f68574a8?s=140&d=retro
Submitted by
RikShep
almost 2 years ago

Why won't this work?! is the lesson bugged or am I missing something?

So this is my code. I have looked for the answers in this forum but nobodys answer works.

<?php
// Create an array with several elements in it,
// then sort it and print the joined elements to the screen
$thearray = array(5, 3, 7);
sort($the
array);
print join(", ", $the_array);
?>

<?php
// Reverse sort your array and print the joined elements to the screen
$thearray = array(5, 3, 7);
print join(" ,", $the
array);
rsort($the_array);

?>

I just get this answer.

Oops, try again. Your reverse sorted array should have at least 3 elements in it. Make sure to pass a comma as the first argument to join() !

BTW $thearray is underscored. but it doesnt show up here.


0 votes

permalink

create a new array underneath, dont re-use the first one.

It should work

call it $new_array eg.

also you have underscores and non underscores in your variables??

518 points
7787a9356cde0634db048f2ea499c0bb?s=140&d=retro
Submitted by
sgibby80
almost 2 years ago