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.
<?php
$array = array(1, 2, 3, 4);
print_r($array);
echo(“<br />”);
$array = array(“Joe”, “Paul”, “Lisa”);
print_r($array);
echo(“<br />”);
$array = array(“Name”=>”Joe”,”Address”=>”123 N Main Street”,”Phone”=>”414-555-5555″);
print_r($array);
?>
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().