PHP如何解析这种格式的文件
<!-- Code highlighting produced by Actipro CodeHighlighter (freeware) http://www.CodeHighlighter.com/ --> <accounts> user=15@220 bindlan=none auto_bindmac=yes cn=包 user=16@613 auto_bindmac=yes bindlan=none cn=包 user=15@116 bindlan=none cn=- desc=- maxlogin=1
$s =
user=15@220 bindlan=none auto_bindmac=yes cn=包
user=16@613 auto_bindmac=yes bindlan=none cn=包
user=15@116 bindlan=none cn=- desc=- maxlogin=1
TXT;
$s = str_replace(' ', "\n", $s);
$s = str_replace('', "]", $s);
$p = parse_ini_string($s, 1);
print_r($p);
<br><font color="#e78608">------解决方案--------------------</font><br>
$s =
user=15@220 bindlan=none auto_bindmac=yes cn=包
user=16@613 auto_bindmac=yes bindlan=none cn=包
user=15@116 bindlan=none cn=- desc=- maxlogin=1
TXT;
preg_match_all("/[\S]+=[^\s]*/",$s,$c);
print_r($c);
<br><font color="#e78608">------解决方案--------------------</font><br>楼上2种方法都可以<br><br><br>郑州PHP.Net<br>http://www.zzphp.net/
<br><font color="#e78608">------解决方案--------------------</font><br>parse_ini_string 第一次看到呢. <div class="clear"></div>
PHP怎么学习?PHP怎么入门?PHP在哪学?PHP怎么学才快?不用担心,这里为大家提供了PHP速学教程(入门到精通),有需要的小伙伴保存下载就能学习啦!
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号