[SOLVED] problem with arrays

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
exo
Forum Newbie
Posts: 2
Joined: Sat Oct 09, 2004 8:18 am

[SOLVED] problem with arrays

Post 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]
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

You really should read [php_man]array[/php_man] then post here

and it is echo $gebaeude["Möbel"]["sitzen"];
exo
Forum Newbie
Posts: 2
Joined: Sat Oct 09, 2004 8:18 am

Post by exo »

sry solved problem my self
it must be ["Möbel"]["sitzen"]
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post 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..
Post Reply