函数原型
extract_from_markers( string $filename, string $marker ): string[]
函数描述
Extracts strings from between the BEGIN and END markers in the .htaccess file.
是否弃用
未弃用
函数参数
-
$filename
string
Required - Filename to extract the strings from.
-
$marker
string
Required - The marker to extract the strings from.
函数返回值
string[] An array of strings from a file (.htaccess) from between BEGIN and END markers.
函数位置
File: wp-admin/includes/misc.php.
函数源码
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 ) {
if ( '#' === substr( $markerline, 0, 1 ) ) {
continue;
}
$result[] = $markerline;
}
if ( false !== strpos( $markerline, '# BEGIN ' . $marker ) ) {
$state = true;
}
}
return $result;
}
源码链接
变更日志
| Version | Description |
|---|---|
| 1.5.0 | Introduced. |

