Array Functions II Codeacademy PHP Example

Array Functions II Codeacademy PHP Example

Here is a correct example for “Array Functions II” from the PHP course.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
<html>
    <p>
	<?php
	// Create an array with several elements in it,
	// then sort it and print the joined elements to the screen
    $the_array = array("Orange", "Grape", "Apple");
    $sort = sort($the_array);
 
    print join(", ", $the_array);
	?>
	</p>
	<p>
	<?php
	// Reverse sort your array and print the joined elements to the screen
    $the_array = array("Orange", "Grape", "Apple");
    $sort = rsort($the_array);
 
    print join(", ", $the_array);
	?>
	</p>
</html>

Add a comment: