This forum is now read-only. Please use our new forums! Go to forums

0 points
Submitted by Techno Feline
about 9 years

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> 

Answer 550b025495e378199f003d78

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>
points
Submitted by Mar-k
about 9 years

1 comments

sofiabeans27 almost 9 years

SO smart! Thank u so much!

Answer 550f03a176b8fe6fb2003abe

1 vote

Permalink

it worked thanks:)

points
Submitted by MissPotato201
about 9 years