我想从smb.conf获取关于共享文件夹[share]和路径“path =”的数据,但我想跳过一行;和// 感谢您的回答。如何使用file_get_contents和preg_match从文件中获取特定数据
样品的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); }
?>
你已经做了什么来尝试解决这个问题? – Rottingham
@Roman:我编辑了你的帖子;将您的评论复制到帖子中。 –