Screenshot 2015-02-14 at 15.42.08

Different Ways Of Defining Arrays In PHP

How to define an empty array ?

$my_array_1 = array();

How to define an auto incremented array?

$my_array_2 = array(“one_1″,”two_2″,”three_3″);

How to define a multidimensional array ?

$multi_dim_array = array();
$multi_dim_array[] = array(“one_1″,”two_2″);
$multi_dim_array[] = array(“three_3″,”four_4″);
echo $multi_dim_array[0][1];
echo $multi_dim_array[1][0];

How to define an array with assigned index stings ?

$my_array_4 = array(
“gender” =>”male”

How to define an array having assigned index numbers?

$my_array_3 = array

Leave a Reply

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

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>