This shows you the differences between two versions of the page.
kurs:hash-of-hashes.php [2014/09/10 21:22] |
kurs:hash-of-hashes.php [2014/09/10 21:22] (current) |
||
---|---|---|---|
Line 1: | Line 1: | ||
+ | <code> | ||
+ | <?php | ||
+ | $tn[] = 'Sofia'; | ||
+ | $tn[] = 'Roman'; | ||
+ | /* | ||
+ | print "$tn[0] \n"; | ||
+ | print "$tn[1] \n"; | ||
+ | */ | ||
+ | |||
+ | $tn2 = array( | ||
+ | 'Sofia' => array('alter' => 54, 'ps' => ''), | ||
+ | 'Roman' => array('alter' => 37, 'ps' => 'php'), | ||
+ | 'Honglei' => array('alter' => 15, 'ps' => 'VB'), | ||
+ | 'Ludwig' => array('alter' => 52, 'ps' => 'java'), | ||
+ | 'Franz' => array('alter' => 49, 'ps' => 'c++'), | ||
+ | 'Mario' => array('alter' => 52, 'ps' => 'vba'), | ||
+ | 'Bernhard'=> array('alter' => 43, 'ps' => 'perl'), | ||
+ | ); | ||
+ | |||
+ | $tn2['Mark'] = array('alter' => 34, 'ps' => 'perl'); | ||
+ | |||
+ | print_r($tn2); | ||
+ | |||
+ | foreach ($tn2 as $teilnehmer => $p) { | ||
+ | printf("%s: Alter: %s PS: %s\n", | ||
+ | $teilnehmer, $p['alter'], $p['ps']); | ||
+ | } | ||
+ | |||
+ | foreach ($tn2 as $teilnehmer => $p) { | ||
+ | printf("Teilnehmer: %s \n", $teilnehmer); | ||
+ | foreach ($p as $eigenschaft => $wert) { | ||
+ | printf("Eigenschaft: %s Wert: %s\n", | ||
+ | $eigenschaft, $wert); | ||
+ | } | ||
+ | } | ||
+ | |||
+ | ?> | ||
+ | </code> |