开发者

Declaring an array

$a[]="Anna";
$a[]="Brittany";
$a[]="Cinder开发者_运维知识库ella";
$a[]="Diana";
$a[]="Eva";
$a[]="Fiona";
$a[]="Gunda";

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


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


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();


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.


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


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜