【发布时间】:2014-01-07 19:14:53
【问题描述】:
我想从 smb.conf 获取有关共享文件夹 [share] 和路径“path =”的数据,但我想跳过行;和 // 感谢您的回答。
示例 smb.conf
;[profiles]
; comment = Users profiles
; path = /home/samba/profiles
; create mask = 0600
; directory mask = 0700
[share]
comment = Ubuntu File Server Share
path = /storage/share
read only = no
guest ok = yes
browseable = yes
create mask = 0755
我试过了,但无法显示路径:
<?php
$smb = file('smb.conf');
foreach ($smb as $line) {
$trim_line = trim ($line);
$begin_char = substr($trim_line, 0, 1);
$end_char = substr($trim_line, -1);
if (($begin_char == "#") || ($begin_char == ";" || $trim_line == "[global]")) {
}
elseif (($begin_char == "[") && ($end_char == "]")) {
$section_name = substr ($trim_line, 1, -1); echo $section_name . '<br>';
}
} //elseif ($trim_line != "") { // $pieces = explode("=", $trim_line , 1); }
?>
【问题讨论】:
-
你做了什么来尝试解决这个问题?
-
@Roman:我已经编辑了你的帖子;将您的评论复制到帖子中。
标签: php preg-match file-get-contents preg-match-all trim