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]Mehrere Inhalte einer HTML Datei auslesen

Empfohlene Antworten

Veröffentlicht

Hallo,

ich habe hier eine HTML Datei, welche im Quellcode mehrere Einträge enthält, die sich dadurch erkenntlich zeigen, dass Sie in einem

<FONT color=#800080>Daten XY</FONT>

hinterlegt werden. Anders ausgedrückt, diese Daten werden auf der HTML Seite farblich hervorgehoben. Nun möchte ich aus dem Quellcode der Datei alle Einträge, die wie in dem Quellcode beschrieben hinterlegt sind, auslesen.

Ich habe bereits schon ein wenig herum experimentiert, allerdings bekomme ich immer nur den ersten Wert, und dann kommen keine Daten mehr:


<?php
$Datei = "test.htm";

$bla = file_get_contents($Datei);
$zeile = str_replace("\r","",$bla);

$pattern = '§\w*<FONT color=#800080>(.+)</FONT>\w*§';

while (preg_match($pattern, $zeile, $txt))
{
echo $txt[1]."\n";
$zeile = $txt[1]." test ".$txt[6];
}

?>
[/PHP]

Kann mir jemand helfen?!

<FONT color=#800080>Daten XY</FONT>

Ich hätte den Regex mal wie folgt aufgebaut:

$pattern = '/<FONT color=#800080>(.+?)<\/FONT>/'; 

(beachte das Fragezeichen!)

Und dann nochmal ins Manual schauen, was genau preg_match eigentlich für ein Array in Deinem $txt speichert, vgl. auch preg_match_all;)

Perfekt...vielen Dank!!!

Es klappt!!!

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.