• Jetzt anmelden. Es dauert nur 2 Minuten und ist kostenlos!

Array generieren - und dann anzeigen

bidu2004

Neues Mitglied
Hallo Forum,

ich will gerade ein Lernprogramm mit PHP schreiben. Aber die Arrays werden nicht angezeigt. Kann mir jemand helfen?
PHP:
<?php
    $lat = "array(Romam, Romae, ire, ante, alienus aliena alienum, equus, ubi...?, noster nostra nostrum, adiuvare, )​​​​​​​​​​​";
    $deu = "array(nach Rom, in Rom, gehen reisen, vor, fremd, Pferd, Wo...?, unser)";
    echo $lat[0];
    ?>
P.S. Es ist noch nicht fertig, ich wollte erst die Lateinwörter in Arrays schreiben.;)
 
Werbung:
In Deinem Code sind keine Arrays. Nur zwei Strings.

Strings werden mit einem " eingeleitet.

Der Inhalt Deines Strings $lat ist also "array(Romam, ...".

Du willst schreiben $lat=array("Romam", "Romae", ...);
 
Ja das hab ich jetzt gemacht, allerdings kommt folgende Meldung:
syntax error, unexpected T_STRING, expecting ')'
Der array sieht jetzt so aus:
PHP:
$lat=array("Romam", "Romae", "ire", "ante", "alienus aliena alienum", "equus", "ubi...?", "noster nostra nostrum","adiuvare",);
 
Werbung:
Dann liegt der Fehler woanders. Du hast mit großer Wahrscheinlichkeit einen String nicht richtig geschlossen. Wenn Dein Editor Syntax-Highliting hat, dann findest Du es vielleicht auch selber.

Ansonsten brauchen wir den gesamten Code und die Zeile, wo der Fehler gemeldet wird.
 
Werbung:
PHP:
<html>
  <head>
    <title>Latein lernen</title>
    <style>
      body { background-color:#ff0000; }
    a.cssmenu:link 
     {
      width : 80px;
      color : black;
      background-color : #ccccff;
      text-align : center;
      text-decoration : none;
      font-size : 12px;
      border-top : 1px solid silver;
      border-right : 1px solid black;
        border-left : 1px solid silver;
        border-bottom : 1px solid black;
        padding-top : 2px;
        padding-right : 4px;
        padding-left : 4px;
        padding-bottom : 2px;
        margin-right : 2px;
      }
      a.cssmenu:visited
      {
      width : 80px;
      color : black;
      background-color : #ccccff;
      text-align : center;
      text-decoration : none;
      font-size : 12px;
      border-top : 1px solid silver;
      border-right : 1px solid black;
        border-left : 1px solid silver;
        border-bottom : 1px solid black;
        padding-top : 2px;
        padding-right : 4px;
        padding-left : 4px;
        padding-bottom : 2px;
        margin-right : 2px;
      }
      a.cssmenu:hover
      {
      width : 80px;
      color : black;
      background-color : #ffff99;
      text-align : center;
      text-decoration : none;
      font-size : 12px;
      border-top : 1px solid silver;
      border-right : 1px solid black;
        border-left : 1px solid silver;
        border-bottom : 1px solid black;
        padding-top : 2px;
        padding-right : 4px;
        padding-left : 4px;
        padding-bottom : 2px;
        margin-right : 2px;
      }

      </style>
  </head>
<body>
  <h1>Lectio 6</h1><br>
  <?php
    $lat=array("Romam", "Romae", "ire", "ante", "alienus aliena alienum", "equus", "ubi...?", "noster nostra nostrum","adiuvare");
   $deu=array(nach Rom, in Rom, gehen reisen, vor, fremd, Pferd, Wo...?, unser);
    echo $lat["0"];
    ?>
  </body>
</html>
​
Kompletter Code. Fehler ist auf Linie 67.
Hier die Seite
 
Äh, hallo? Du hast ja nur den Fehler für $lat korrigiert.
$deu ist ja immer noch falsch, da fehlen die Anführungszeichen.
Außerdem muss es dann $lat[0] heißen
 
array mit text:
PHP:
$foo = array("text1", "text2", "text3");
array mit zahlenwerten
PHP:
$foo = array(1,2,3,4);
array mit variablen:
PHP:
$foo = array($bar, $foofoo, $foobar);

und das aller wichtigste zur selbsthilfe.. array()
 
Werbung:
Zurück
Oben