【发布时间】:2012-07-10 14:53:18
【问题描述】:
我在 PHP 中发现了一些奇怪的东西,如果我使用数字数组,第 8 个数组会被忽略,这里当我将 'Cherry' 放入 $fruit[08] 时,php 接缝会越过它。
发生了什么事?这是一个错误还是其他什么。
<pre>
<?php
$fruit[01] = "Apples";
$fruit[02] = "Pears";
$fruit[03] = "Bananas";
$fruit[04] = "Grape";
$fruit[05] = "Orange";
$fruit[06] = "Peach";
$fruit[07] = "Lemon";
$fruit[08] = "Cherry";
$fruit[09] = "Mango";
print_r($fruit);
?>
</pre>
输出:
Array
(
[1] => Apples
[2] => Pears
[3] => Bananas
[4] => Grape
[5] => Orange
[6] => Peach
[7] => Lemon
[0] => Mango
)
【问题讨论】:
-
几乎可以肯定是“别的东西”。打印数组的输出是什么?
-
尝试设置不带0(零)的数组索引
标签: php