There should be no comma after the last element in an array.
Code: Select all
$doc = array (
1 => array ("Oliver", "Peter", "Paul"),
2 => array ("Marlene", "Lucy", "Lina"), //<--- bad comma
);
The problem with the following code is the semicolon.
Code: Select all
3 => ($rowone); //<--- bad semicolon
This works:
Code: Select all
<?php
header('Content-Type: text/plain');
for ($x = 0; $x < 5; $x++) {
$rowone[$x] = $x;
}
$doc = array
( 1 => array('Oliver', 'Peter', 'Paul')
, 2 => array('Marlene', 'Lucy', 'Lina')
, 3 => $rowone
);
print_r($doc);
?>
The output is:
Code: Select all
Array
(
[1] => Array
(
[0] => Oliver
[1] => Peter
[2] => Paul
)
[2] => Array
(
[0] => Marlene
[1] => Lucy
[2] => Lina
)
[3] => Array
(
[0] => 0
[1] => 1
[2] => 2
[3] => 3
[4] => 4
)
)
Edit: This post was recovered from search engine cache.