Re: multi-dimensional array
| From: | Miguel Cruz | Date: | Thu, 09 May 2002 21:22:13 +0000 |
| Subject: | Re: multi-dimensional array | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-96870@lists.php.net to get a copy of this message | ||
Line 25 looks like this:
$division[$div_id][$array]=array();
The first subscript to division is $div_id, which is fine.
The second one is $array, which is an array. That doesn't make any sense.
Array keys have to be strings or numbers. You'd have to create a separate
array at each subscript of $division[$div_id] ...
foreach ($array as $k => $v)
$division[$div_id][$k] = array();
miguel
On Thu, 9 May 2002, Steve Buehler wrote:
> I am trying to learn some new things in the hopes that it would help me
> with my mysql/PHP programming. The following code gives me an error: "
> Warning: Illegal offset type in z.php on line 25 ".
>
> $result=mysql_query("SELECT * FROM division");
> while(($row=mysql_fetch_object($result))){
> $div_id=$row->div_id;
> $array=array("sub1" => $row->sub1,
> "sub1d" => $row->sub1d,
> "sub2" => $row->sub2,
> "sub2d" => $row->sub2d,
> "sub3" => $row->sub3,
> "sub3d" => $row->sub3d,
> "sub4" => $row->sub4,
> "sub4d" => $row->sub4d,
> "sub5" => $row->sub5,
> "sub5d" => $row->sub5d,
> "game_length" => $row->game_length);
> // The following is the line 25
> $division[$div_id][$array]=array();
> }
>
> What I am trying to do is to be able to later call $division[$div_id][sub5]
> etc... I sure hope that this can be done. If not, I will just have to
> stick with temporary tables.
>
> Thanks
> Steve
>