Eine auf WordPress spezialiserte Suchmaschine für Entwickler und Theme-Autoren



extract_from_markers ›

Seit1.5.0
Veraltetn/v
extract_from_markers ( $filename, $marker )
Parameter: (2)
  • (string) $filename
    Erforderlich: Ja
  • (string) $marker
    Erforderlich: Ja
Gibt zurück:
  • (array) An array of strings from a file (.htaccess ) from between BEGIN and END markers.
Definiert in:
Codex:

Extracts strings from between the BEGIN and END markers in the .htaccess file.



Quellcode

function extract_from_markers( $filename, $marker ) {
	$result = array();

	if ( ! file_exists( $filename ) ) {
		return $result;
	}

	$markerdata = explode( "\n", implode( '', file( $filename ) ) );

	$state = false;
	foreach ( $markerdata as $markerline ) {
		if ( false !== strpos( $markerline, '# END ' . $marker ) ) {
			$state = false;
		}
		if ( $state ) {
			$result[] = $markerline;
		}
		if ( false !== strpos( $markerline, '# BEGIN ' . $marker ) ) {
			$state = true;
		}
	}

	return $result;
}