PHP array() Function

Create an indexed array named $name, assign two elements to it, and then print a text containing the array values.

In PHP, there are three types of arrays.

Indexed arrays – Arrays with numeric index

Associative arrays – Arrays with named keys

Multidimensional arrays – Arrays containing one or more arrays

$name = array("Alex","24");
echo "My name is ".$name[0]. " and my age ".$name[1]. ".";

Ouptput

My name is Alex and my age 24.

Leave a Reply

Your email address will not be published. Required fields are marked *