Page 1 of 1

[SOLVED] problem with arrays

Posted: Sat Oct 09, 2004 8:23 am
by exo
feyd | Help us, help you. Please use

Code: Select all

and

Code: Select all

tags where approriate when posting code. Read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]


hi i've just started learning php and read a tutorial that included the following example:

Code: Select all

<html>
<?php
$gebaeude = array(
    "Möbel"  => array("liegen"=>"Bett","liegen"=>"Sessel","sitzen"=>"Stuhl"),
    "Häuser" => array("Einfamilienhaus",2 => "Mehrfamilienhaus",3 => "Reihenhaus"),
    "Garagen"   => array("für 1 Auto", "für zwei Autos", "Tiefgarage")
);
echo $gebaeude["Möbel","sitzen"]; // Sessel da der zweite Wert mit demselben Segment den ersten überschreibt 
?>
</html>
but if i try to run it this error is showed:

Code: Select all

Parse error: parse error, unexpected ',', expecting ']' in C:\Apache\htdocs\array2.php on line 8
echo $gebaeude["Möbel","sitzen"]; (this is line 8 )


feyd | Help us, help you. Please use

Code: Select all

and

Code: Select all

tags where approriate when posting code. Read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]

Posted: Sat Oct 09, 2004 8:26 am
by John Cartwright
You really should read [php_man]array[/php_man] then post here

and it is echo $gebaeude["Möbel"]["sitzen"];

Posted: Sat Oct 09, 2004 8:31 am
by exo
sry solved problem my self
it must be ["Möbel"]["sitzen"]

Posted: Sat Oct 09, 2004 8:34 am
by John Cartwright
exo wrote:sry solved problem my self
it must be ["Möbel"]["sitzen"]
maybe you should presh refresh when waiting for replies..