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.

php einzelne zeilen auslesen

Empfohlene Antworten

Veröffentlicht

hi ich mach seit neusten ein bischen php jetzt bin ich aber auf ein pro gestossen und komm irgendwie nicht weiter!

aslo ich hab ne text datei wo ich eine bestimmte anzahl zeilen anhänge und dann wieder schliesse das funktioniert auch wunderbar! aber wie lese ich jetzt z.b. zeile 5 aus??

hie hab ich mal den code eingefügt:

<?php

$datei=fopen("test.txt","a+");

while (!feof($datei)) {

$zeile = fgets($datei,1000);

echo $zeile;

}

fwrite($datei, "Eine weiter zeile\n");

fclose($datei);

?>

also bitte helft mir bis dann

Original geschrieben von Deschdrozer

hi ich mach seit neusten ein bischen php jetzt bin ich aber auf ein pro gestossen und komm irgendwie nicht weiter!

aslo ich hab ne text datei wo ich eine bestimmte anzahl zeilen anhänge und dann wieder schliesse das funktioniert auch wunderbar! aber wie lese ich jetzt z.b. zeile 5 aus??

hie hab ich mal den code eingefügt:

<?php

$datei=fopen("test.txt","a+");

while (!feof($datei)) {

$zeile = fgets($datei,1000);

echo $zeile;

}

fwrite($datei, "Eine weiter zeile\n");

fclose($datei);

?>

also bitte helft mir bis dann

<?php

$i = 0;

$datei=fopen("test.txt","a+");

while (!feof($datei)) {

$i++;

$zeile = fgets($datei,1000);

if($i==4){

echo $zeile;

}

}

fwrite($datei, "Eine weiter zeile\n");

fclose($datei);

?>

Ein Vorschlag auf die schnelle, gibt aber bestimmt auch bessere Möglichkeiten.

MfG:)

Verschoben ins PHP-Forum

Und wenn man es einfach haben will:

<?

$zeilen=file("dateiname");

$zeile5=$zeilen[4];

?>

file() liest eine datei ein und schreibt sie in ein array.. jede zeile ist ein element.

Michael

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.