PHP parses the file XMLcode & lt; accounts & gt; user15 @ 220bindlannoneauto_bindmacyescn package user16 @ 613auto_bindmacyesbindlannonecn package user15 @ 116bindlannonecn-desc-maxl PHP how to parse files in this format
XML code
User = 15 @ 220 bindlan = none auto_bindmac = yes cn = package user = 16 @ 613 auto_bindmac = yes bindlan = none cn = package user = 15 @ 116 bindlan = none cn =-desc =-maxlogin = 1
Without explode, resolve the preceding format to an array, for example, $ a [accounts] [user] = '15 @ 220 '.
Explode is the next policy. can one of the many PHP functions parse such format files? Functions similar to parse_ini_file
------ Solution --------------------
PHP code
$ S = <TXTuser = 15 @ 220 bindlan = none auto_bindmac = yes cn = package user = 16 @ 613 auto_bindmac = yes bindlan = none cn = package user = 15 @ 116 bindlan = none cn =-desc =-maxlogin = 1TXT; $ s = str_replace (''," \ n ", $ s); $ s = str_replace ('<'," [", $ s ); $ s = str_replace ('>', "]", $ s); $ p = parse_ini_string ($ s, 1); print_r ($ p );
------ Solution --------------------
PHP code
$ S = <TXTuser = 15 @ 220 bindlan = none auto_bindmac = yes cn = package user = 16 @ 613 auto_bindmac = yes bindlan = none cn = package user = 15 @ 116 bindlan = none cn =-desc =-maxlogin = 1TXT; preg_match_all ("/[\ S] + = [^ \ s] */", $ s, $ c); print_r ($ c );
------ Solution --------------------
Either of the two methods can be used upstairs.
Zhengzhou PHP. Net
Http://www.zzphp.net/
------ Solution --------------------
Parse_ini_string: the first time you see it.