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

Functions, Part I Forum

View Course » View Exercise

1199 points
55145f76d3292fcd00000e98_971822644
Submitted by
Techno Feline
about 2 years ago

Solution for Array Functions II 8/8

This is my solution.

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

3 votes

permalink

Try to resort your array first before printing again:

<html>
<p>
<?php
// Create an array with several elements in it,
// then sort it and print the joined elements to the screen
$array = array(5 ,3 ,8 ,1);
sort($array);
print join(",", $array);
?>
</p>
<p>
<?php
// Reverse sort your array and print the joined elements to the screen
rsort($array);
print join(", ", $array);

?>
</p>

95 points
04d0a41258a573fcbd998591d9793d34?s=140&d=retro
Submitted by
Mark_FHICT
about 2 years ago

1 Comment

D74f3e8f6ac51c03fee857f664b33d34?s=140&d=retro sofiabeans27 almost 2 years ago

SO smart! Thank u so much!


1 vote

permalink

it worked thanks:)

547 points
55e7642086f55250390004dc_31640069
Submitted by
MissPotato201
about 2 years ago