Array Functions I Codeacademy PHP Example

Array Functions I Codeacademy PHP Example

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

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
<html>
    <p>
	<?php
	// Create an array and push 5 elements on to it, then 
    // print the number of elements in your array to the screen
    $fruits = array();
    array_push($fruits, "Orange");
    array_push($fruits, "Apple");
    array_push($fruits, "Grapes");
    array_push($fruits, "Lemons");
    array_push($fruits, "Strawberries");
 
    print count($fruits);
	?>
	</p>
</html>

Add a comment: