tags:

views:

73

answers:

5
$a[]="Anna";
$a[]="Brittany";
$a[]="Cinderella";
$a[]="Diana";
$a[]="Eva";
$a[]="Fiona";
$a[]="Gunda";

When declaring it this way, does it automatically increase the index? Why is this ideal?

+5  A: 

Yes it does. It may not be ideal for you, but it sure is convenient for most people.

Dominic Rodger
A: 

Yes, it does. It may not be 'ideal' - but considering that you're setting an array equal to a single value, adding to the array is better than overwriting the entire array, which I suppose would be the other option for that statement.

b. e. hollenbeck
A: 

Yes, It automatically increasing a index but start with '0'.

Deepali
+1  A: 

Yes, it does. See the PHP arrays guide. Note that if you want to delete the array, you can use:

unset($a);

Or if you want to make $a become an empty array, you can use:

$a = array();
Michael Aaron Safyan
+1 for actually linking to the [docs](http://php.net/manual/en/language.types.array.php#language.types.array.syntax.modifying). Seriously, people.
Adam Backstrom
A: 

Yes its ideal, because if its not, then use an associative array.

Babiker