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] preg_replace liefert zwei <br> statt einem

Empfohlene Antworten

Veröffentlicht

Hallo,

folgendes Problem. Ich durchsuche einen String nach Absätzen, also nach \n bzw. \r. Diese sollen dann durch einen HTML-konformen <br>-Tag ersetzt werden. Die Funktion funktioniert auch soweit, allerdings liefert er mir immer zwei <br> anstatt nur einem ("Das ist Zeile eins.<br><br>Zeile 3, obwohl es Zeile 2 sein soll, ein br-tag ist zuviel"). Das nervt mal. :/

Hier mal ein Teil des Codes:

$input = "$datum|$name|$email|$www|$beitrag|$ip";
$input = preg_replace("/\r\n|\r|\n/", "<br>", $input);
$umbruch = "\n";
$input .= $umbruch;[/PHP]

Dass ich nach dem ersetzen noch ein \n hinter den String setze, ist, um das Ende eines Beitrages zu markieren (lese die Beiträge mit fgets zeilenweise aus). Aber das geschieht ja _nach_ dem Ersetzen, das schließe ich also als Fehlerquelle aus.

Hoffe, mir kann da einer weiterhelfen.

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.