Thema: PHP foreach
Einzelnen Beitrag anzeigen
Alt 18.06.2006, 12:39   #1
athropos
Hero
 
Registriert seit: 24.07.2001
Alter: 46
Beiträge: 801


athropos eine Nachricht über Skype™ schicken
Standard PHP foreach

Hi!

Irgendwie steig ich nicht dahinter, wie das mit dem foreach-Befehl bei php funzt

Gegeben ist (in etwa, sind nur Testdaten) folgendes (2dimensionales) Array
Code:
$liste = array(
  	array('NR'=>1,'Name'=>'gandalf','LeistungTyp'=>'wizard', 'Betrag' => '25')
	,array('NR'=>2,'Name'=>'bilbo','LeistungTyp'=>'hobbit', 'Betrag' => '35')
	,array('NR'=>3,'Name'=>'frodo','LeistungTyp'=>'hobbit','Betrag' => '46')
	,array('NR'=>4,'Name'=>'saruman','LeistungTyp'=>'bad dude','Betrag' => '57')
	,array('NR'=>5,'Name'=>'sauron','LeistungTyp'=>'really bad dude', 'Betrag' => '99')
  );
ich möchte nun einerseits das Array Tabellarisch ausgeben, andererseits im Zuge des Durchlaufs die Beträge summieren und am Ende die Summe bilden.

Wie genau mach ich das?

thx & lg,
Athropos
____________________________________
Einstein, Pascal and Newton are playing hide and seek. Einstein is \"it\" so he faces the wall, closes his eyes and counts to π.
Pascal runs off like an idiot but Newton pulls out a piece of chalk and draws a 1m x 1m square on the ground and then stands in it\'s centre.

Einstein\'s done counting and turns around and sees Newton, so he grabs him and screams \"I found Newton!\"

Then Newton smirks and says, \"I\'m not Newton, I\'m Pascal\".
athropos ist offline   Mit Zitat antworten