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

Functions, Part I Forum

View Course » View Exercise

251 points
Fefb5feb1ec4cd84aa2b6ce8f11a6eb7?s=140&d=retro
Submitted by
Luke_Volpe
almost 3 years ago

Why won't my code work? 7/8

My error message says that my reverse sorted array should have at least 3 elements in it but it already has 4?

This is the code that I used:

<html>
<p>
<?php
$the_array = array(1, 3, 5, 7);
sort($the_array);
print join(",", $the_array);
?>
</p>
<p>
<?php
rsort($the_array);
print join(":", $the_array);
?>
</p>

4 votes

permalink

Change the line:
print join(":", $the_array);
to:
print join(",", $the_array);
The trouble is you were using a colon (":") instead of a comma (",").

559 points
95c6e6c26f3dcc6f9db3c6a5c52b4e61?s=140&d=retro
Submitted by
mathiasfoster
almost 3 years ago


1 vote

permalink

I had a weird glitch and I just hit Save and Submit Code! and it worked! I don't think you need to add any code at all. Just reset and hit Save and Submit Code!. It worked for me, so it might work for you.

1152 points
577fe3b0e92d41a79f000240_732657284
Submitted by
CaptainKA
almost 3 years ago

1 Comment

Picture Bill over 2 years ago

This PHP course is full of bugs like that, you type in the right stuff and it tells you you're wrong. Then you just erase a semicolon and re-type it and then it works...


0 votes

permalink

I just tried your code and it worked for me!

251 points
Picture
Submitted by
Magayane
almost 3 years ago

3 Comments

Fefb5feb1ec4cd84aa2b6ce8f11a6eb7?s=140&d=retro Luke_Volpe almost 3 years ago

it's still not working for me though:/

Picture Joseph Edward almost 3 years ago

I'm having the same problem.

55b57beae295dd9f7f7ca05b2f2bd155?s=140&d=retro Patrick DeVito almost 3 years ago

on your second join, use a , instead of : and it works.