How does PHP read all the content of a node in the INI file? -Php Tutorial

Source: Internet
Author: User
How does PHP read all the content of a node in the INI file? Suppose there is an ini file (aa. ini) with the following content:
[Aa]
AB = 12
Ac = 123
Ad = 1234

[Bb]
Bb = 22
Bc = 343
The items in [aa] and [bb] are not fixed. how can I read only the content of all nodes in [aa?

Thank you!


Reply to discussion (solution)

$ Tmp = parse_ini_file (INI file, true );
$ Aa = $ tmp ['A'];

If you are using php> = 5.4
$ Aa = $ tmp = parse_ini_file (INI file, true) ['A'];

$ Tmp = parse_ini_file (INI file, true );
$ Aa = $ tmp ['A'];



If echo $ aa; is added, why is it displayed as an Array instead of data?

If you are using php> = 5.4
$ Aa = $ tmp = parse_ini_file (INI file, true) ['A'];



Do I still need to use for loop acquisition?

Why don't you just use it?
Echo $ aa ['AB'];
No?

That's an array. echo is not acceptable.


$ Tmp = parse_ini_file (INI file, true );
$ Aa = $ tmp ['A'];



If echo $ aa; is added, why is it displayed as an Array instead of data?

Why don't you just use it?
Echo $ aa ['AB'];
No?



I want everything, not the content of a single branch. I want to read all the content in [aa], and AB, ac, and ad are unknown, not known.

You didn't meanHow can I read only the content of all nodes in [aa?

Foreach ($ aa as $ k =>$ v ){
// Do your operations here!
}

Foreach ($ aa as $ k =>$ v ){
// Do your operations here!
}



Can I make it clear? Thank you!

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.