The result of this code:
for($i = 0; $i <= 7; $i++){
$eachone[] = array ('a' => '1', 'b' => '2', 'c' => '3');
$a[] = array($i => $eachone);
unset($eachone);
}
$json_string = json_encode($a);
echo $json_string;
is:
[
[
[
{
"a": "1",
"b": "2",
"c": "3"
}
]
],
{
"1": [
{
"a": "1",
"b": "2",
"c": "3"
}
]
},
{
"2": [
{
"a": "1",
"b": "2",
"c": "3"
}
]
},
{
"3": [
{
"a": "1",
"b": "2",
"c": "3"
}
]
},
{
"4": [
{
"a": "1",
"b": "2",
"c": "3"
}
]
},
{
"5": [
{
"a": "1",
"b": "2",
"c": "3"
}
]
},
{
"6": [
{
"a": "1",
"b": "2",
"c": "3"
}
]
},
{
"7": [
{
"a": "1",
"b": "2",
"c": "3"
}
]
}
]
Can you notice how it's skipping the first number, which is zero? The question is: Why?