Autor Beitrag
WeBsPaCe
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 2322
Erhaltene Danke: 1

FireFox 3, Internet Explorer 6 SP1
D1, D3Prof, D6Pers, D7Pers+Indy, VisualStudio Express
BeitragVerfasst: Di 24.05.05 15:14 
Moin... ;)

Ich finde grad überhaupt nichts zum Erstellen von dynamischen Arrays in PHP. Ich möchte ein Array anlegen, von dem ich erst zur Laufzeit weiß, wie viele Elemente es hat.

Kann mir da bitte jemand helfen? ;)

Danke schonmal,
mfG, cu, WeBsPaCe
I.MacLeod
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 109



BeitragVerfasst: Di 24.05.05 15:22 
Neue Elemente kannst du am einfachsten mit [] anhängen:

ausblenden Quelltext
1:
2:
3:
$foo = array();
$foo[] = 10;
$foo[] = 20;


Ansonsten kannst du dich ja einfach mal hier umgucken:

www.php.net/manual/en/ref.array.php

_________________
{$APPTYPE CONSOLE}uses SysUtils;const a='{$APPTYPE CONSOLE}uses SysUtils;const a=%s;begin write(Format(a,[#39+a+#39]))end.';begin write(Format(a,[#39+a+#39]))end.
StefanH
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 1144

Win XP
D5 Standard, D7 Pers, D2005 Pers
BeitragVerfasst: Di 24.05.05 15:22 
öhm.... array() ?


zuuuuu langsam.

_________________
"Als es noch keine Computer gab, war das Programmieren noch relativ einfach."(Edsger W. Dijkstra)
"Ich bin nicht von Sinnen, sondern ich rede wahre und vernünftige Worte." (Paulus)
smiegel
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 992
Erhaltene Danke: 1

WIN 7
D7 Prof., C#, RAD XE Prof.
BeitragVerfasst: Di 24.05.05 15:26 
Hallo,

die Arrays in PHP sind im Prinzip dynamisch. Eine Funktion analog SetLength() in Delphi gibt es nicht.

Ein Array wird z.B. mit array_push($myarray, $eineVarible) gefüllt. Mit count($myarray) kann man die Anzahl der Elemente ermitteln.

Sollte dies Deine Frage nicht beantworten, wäre u.U. ein Beispiel nicht schlecht.

_________________
Gruß Smiegel
Ich weiß, daß ich nichts weiß, aber ich weiß mehr als die, die nicht wissen, daß sie nichts wissen. (Sokrates)
WeBsPaCe Threadstarter
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 2322
Erhaltene Danke: 1

FireFox 3, Internet Explorer 6 SP1
D1, D3Prof, D6Pers, D7Pers+Indy, VisualStudio Express
BeitragVerfasst: Di 24.05.05 15:34 
Mhmm... Doch, das war's was ich wissen wollte. Dieses komische PHP. Man muss die Länge eines Arrays überhaupt nie festlegen... KoOoOoOomisch... :lol: Ist halt PHP. :mrgreen:

Danke... cu, WeBBy