How does PHP parse files in this format?

Source: Internet
Author: User
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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.