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 - Einlesen von x Substrings

Empfohlene Antworten

Veröffentlicht

Hallo Community,

da ich das Gefühl habe mich im Kreis zu drehen, bitte ich euch um Hilfe bei folgender Aufgabenstellung:

Zwecks Datenerfassung sollen je die ersten 7 Substrings "value=Wert" erfasst werden. Der restliche Inhalt ist irrelevant. Sobald diese erfasst sind - soll die nächste URL aufgerufen werden um selbige 7 Substrings und dessen Werte zur weiteren Verarbeitung einzulesen.

Mittels substr_count - erhalte ich die Anzahl der im String vorkommenden Substrings (15).

Meine Frage ist die folgende:

Wie erhalte ich nur die ersten 7 Substrings aus dem String - der Rest ist praktisch irrelevant.

Gibt es eventuell eine Funktion die mir das Leben erleichtert? Anbei mein bereinigter Code.

Danke im Voraus.


<?php    

$id_hm_nr = 0;

$seperator = "=";

$url="https://hilfsmittel.gkv-spitzenverband.de/produktlisteZurArt_input.action?paramArtId=0";


$pos = strpos($url, $seperator);


while ($id_hm_nr <= 2) {

	$id_hm_nr++;

	$id_value_hm = 0;

	$id_value_beschreibung = "";

	$startpos = 0;

	$i = 0;


	$url_new = substr_replace($url, "=".$id_hm_nr, $pos);	

	$filestream = file_get_contents($url_new);



	$startpos = 0;

	while($pos_val = strpos($filestream, "value=", $startpos)){		

		$string = substr($filestream, $pos_val, strpos($filestream, " ", $pos_val + 1) - $pos_val);		

		$startpos = $pos_val + 1;

		$id_value_hm++;

		echo $string."</br>";

		echo "---------------------------------------------</br>";

	}


}

?> 


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.