Zum Inhalt springen
View in the app

A better way to browse. Learn more.

Fachinformatiker.de

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

array[] in eine Tabelle bringen

Empfohlene Antworten

Veröffentlicht

Hallo an alle

Ich hoffe das ihr mir helfen könnt bei meinem Problem. Ich komme nicht auf die Lösung.

Ich möchte die ausgabe des array[] in eine Table schreiben. 2 Spaltig.

Aber ich bekomme keine Ausgabe. Woran dies liegt kann ich nicht sagen.

Die im unteren Teil des codes auskommentierten Zeilen geben eine ausgabe. Aber nur untereinander. Es sind im ganzen 10 Elemente.

Könt Ihr mir sagen wo mein fehler liegt?

Danke im vorraus für eure hilfe

echo <table>;
for ($ix=0;$ix<count($array[0])+1;$ix++))
{
echo <tr>;
if ($ta mod2 =1)
{
echo <td>
echo '<h3 style="margin-bottom: 0;">'.$array3[0].'</h3>';
echo '<b><i>'.$array3[1].'</i></b>: '.$array3[2] ."<br>" ;
echo '<b><i>'.$array3[3].'</i></b>: '.$array3[4];
echo </td>
}
else
{
echo <td>
echo '<h3 style="margin-bottom: 0;">'.$array3[0].'</h3>';
echo '<b><i>'.$array3[1].'</i></b>: '.$array3[2] ."<br>" ;
echo '<b><i>'.$array3[3].'</i></b>: '.$array3[4];
echo </td>
}
echo </tr>
//print_r($array3);
//echo '<h3 style="margin-bottom: 0;">'.$array3[0].'</h3>';
//echo '<b><i>'.$array3[1].'</i></b>: '.$array3[2] ."<br>" ;
//echo '<b><i>'.$array3[3].'</i></b>: '.$array3[4];

}
echo </table>;[/PHP]

Bist du sicher, dass du auf die Länge des ersten Elements prüfen willst?

for ($ix=0;$ix<count($array[0])+1;$ix++))

Und bitte benutze Anführungszeichen in deinen Strings!

  • Autor

Ich habe den Code ein wenig geändert. Nur leider bekomme ich imer noch keine ausgabe.

echo "<table>";
for ($ix=0;$ix<count($array3[0])+1;$ix++))
{
echo "<tr>";
if ($ta mod2 =1)
{
echo "<td>";
echo '<h3 style="margin-bottom: 0;">'.$array3[0].'</h3>';
echo '<b><i>'.$array3[1].'</i></b>: '.$array3[2] ."<br>" ;
echo '<b><i>'.$array3[3].'</i></b>: '.$array3[4];
echo "</td>";
}
else
{
echo "<td>";
echo '<h3 style="margin-bottom: 0;">'.$array3[0].'</h3>';
echo '<b><i>'.$array3[1].'</i></b>: '.$array3[2] ."<br>" ;
echo '<b><i>'.$array3[3].'</i></b>: '.$array3[4];
echo "</td>";
}
echo "</tr>";
//print_r($array3);
//echo '<h3 style="margin-bottom: 0;">'.$array3[0].'</h3>';
//echo '<b><i>'.$array3[1].'</i></b>: '.$array3[2] ."<br>" ;
//echo '<b><i>'.$array3[3].'</i></b>: '.$array3[4];

}
echo "</table>";[/PHP]

Das komplette array[] soll in eine Zelle geschrieben werden.
Also ist die Information, dass das in eine Tabelle soll, irrelevant. Du machst vor der Array-Ausgabelogik die Zelle auf, und danach wieder zu. Dazwischen (im interessanten Teil) passiert nichts, dass sich auf die Tabelle beziehen würde.

Es gehört zusammen.
Bitte beantworte doch die Frage: In welcher Reihenfolge sollen die Array-Elemente ausgegeben werden?

In deinem Beispielcode (wo allerdings array3 und nicht array ausgegeben wird) gibst du das erste Element als Überschrift aus, und dann jeweils zwei Elemente nebeneinander. Ist das so gewünscht?

Wenn man das fortsetzt, kommt man aber immer auf eine ungerade Anzahl, nicht auf 10.

Archiv

Dieses Thema wurde archiviert und kann nicht mehr beantwortet werden.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.