Home > Backend Development > PHP Tutorial > PHP怎么解析这种格式的文件

PHP怎么解析这种格式的文件

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-13 10:29:08
Original
916 people have browsed it

PHP如何解析这种格式的文件

XML code
<!--Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/--><accounts>[email protected] bindlan=none auto_bindmac=yes cn=包 [email protected] auto_bindmac=yes bindlan=none cn=包 [email protected] bindlan=none cn=- desc=- maxlogin=1</accounts>
Copy after login

再不用explode的情况下,把上面的格式解析成数组,如 $a[accounts][user][email protected]'这种格式

explode是下下策,众多PHP函数,有一个能解析此类格式文件吗?类似于parse_ini_file这种函数

------解决方案--------------------
PHP code
$s = [email protected] bindlan=none auto_bindmac=yes cn=包 [email protected] auto_bindmac=yes bindlan=none cn=包 [email protected] bindlan=none cn=- desc=- maxlogin=1TXT;$s = str_replace(' ', "\n", $s);$s = str_replace('', "]", $s);$p = parse_ini_string($s, 1);print_r($p);<br><font color="#e78608">------解决方案--------------------</font><br>
Copy after login
PHP code
$s = [email protected] bindlan=none auto_bindmac=yes cn=包 [email protected] auto_bindmac=yes bindlan=none cn=包 [email protected] bindlan=none cn=- desc=- maxlogin=1TXT;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>
Copy after login
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template