PHP function of the day: array()

For day 5 of 21 in the “PHP Function of the day” series, I’m going to look at array().  Array() is what you use to create an array in PHP.

Let’s take a look.


$array = array(1, 2, 3, 4);


echo(“<br />”);

$array = array(“Joe”, “Paul”, “Lisa”);


echo(“<br />”);

$array = array(“Name”=>”Joe”,”Address”=>”123 N Main Street”,”Phone”=>”414-555-5555″);




See the output


As you can see above, Array() can take a variety of different argument types.  You can even create a multidimensional array by passing an array into an array().

Leave a Reply

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