Monday, 18 February 2013

Array Creation in PHP

In PHP, we are going to see the variouse ways for creating an array.

Option 1:
$firstArray = array();
$firstArray[] = ‘id’;
$firstArray[] = ‘name’;
$firstArray[] = ‘city’;

Option 2:
$firstArray = array(‘id’,'name’,'city’);

Option 3: // as of PHP 5.4
$firstArray = ['id','name','city'];


Please let me know, if there is any other ways available for creating PHP arrays?

No comments:

Post a Comment