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

Functions, Part I Forum

View Course » View Exercise

349 points
2e25945f08e588affb060df00b863440?s=140&d=retro
Submitted by
Khan128
over 2 years ago

what is the problem ???( 7/8 )anyone help mee

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

?>
</p>
<p>
<?php
// Reverse sort your array and print the joined elements to the screen

$thearray=array(3,1,5);
rsort($the
array);
echo join(":", $the_array);
?>


2 votes

permalink

Hello all,

Please see below my code:

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


<?php
// Reverse sort your array and print the joined elements to //the screen
$the
array = array(7,5,9,10,15);
rsort($thearray);
print join(":", $the
array);
?>

Note: $thearray is actually with underscore but it doesn't showed.

Problem: When I clicked on submit code below error displayed:

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() !

Please help.

393 points
56bd89fef50c68a5560002ad_115962458
Submitted by
SALMAN MUSHTAQ
over 2 years ago


2 votes

permalink

With the second join, you need to put a comma instead of a colon, despite the instructions showing a colon.

"For this exercise, we'll use a comma (,) as the glue."

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


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

353 points
5522a8dad3292f91b90001cf_129218395
Submitted by
danielsmith32
over 2 years ago

1 Comment

2e25945f08e588affb060df00b863440?s=140&d=retro Khan128 over 2 years ago

nicee.thank you


1 vote

permalink

correct $thearray to $the_array

1184 points
593e66c65821220767000153_509673043
Submitted by
ANASTASIIA SISAKET
over 2 years ago


0 votes

permalink

Dont do step 4 "On line 12, rsort() the array."

Put the code on line 16.

237 points
559fb9209113cb56e5000227_472429052
Submitted by
Ryno
over 2 years ago


0 votes

permalink

thanxxxxxxxxxxxxx

349 points
2e25945f08e588affb060df00b863440?s=140&d=retro
Submitted by
Khan128
over 2 years ago