Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7803715
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T01:40:27+00:00 2026-06-02T01:40:27+00:00

— Background — So I am working on a installer script for local dev

  • 0

— Background —

So I am working on a installer script for local dev machines and its for installing word press, What I am trying to do is have it so that the user would select a specific plug in from a drop down box and then from there select which version they want to install.

— Issue —

So I need to be able to parse the .cfg file and store all the values into variables dynamically so that way if we add more plugins it won’t break. How do I go about doing this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T01:40:29+00:00Added an answer on June 2, 2026 at 1:40 am

    Couple of ways, depending on how you wish to store the config data. The fastest way is to store the data as an .ini file and parse it using PHP’s built in parse_ini_file. You could also store the data in other formats such as XML and YAML, but I wouldn’t recommend XML as you probably won’t be transporting the data betweeen disparate systems, also XML tends to be harder to read with all the extraneous tags (vs yaml or ini).

    I personally prefer yaml and use Symfony’s Yaml Component parser which will parse the yaml file into an array. Symfony’s Yaml Component can be used outside of the Symfony framework. You could also look into Zend’s Yaml parser as well.

    After you pick the format and parser you wish to use, it’s as easy as storing the config file somewhere that is accessible by your webserver, requiring it, and passing it through the parser API. After it is parsed you should have access to the values via an array.

    — Update —

    <?php
    
    $settings = parse_ini_file('test.ini');
    
    var_dump($settings);
    

    Results:

    array(41) {
    ["plugins"]=>
    string(0) ""
    ["breadcrumb-navxt"]=>
    string(5) "4.0.1"
    ["bp-moderation"]=>
    string(5) "0.1.4"
    ["buddypress-activity-stream-hashtags"]=>
    string(5) "0.4.0"
    ["buddypress-group-documents"]=>
    string(5) "0.3.5"
    ["buddypress-group-email-subscription"]=>
    string(5) "2.9.1"
    ["buddypress-links"]=>
    string(3) "0.5"
    ["buddypress"]=>
    string(6) "1.2.10"
    ["calendar"]=>
    string(5) "1.3.1"
    ["collapsing-pages"]=>
    string(5) "0.6.1"
    

    This appears to work as expected, so if I want the version number of the calendar plug-in I would just do:

    var_dump($settings['calendar']);
    

    To store in dynamic variables:

    $settings = parse_ini_file('test.ini');
    
    foreach ($settings as $key => $setting) {
        // Notice the double $$, this tells php to create a variable with the same name as key
        $$key = $setting; 
    }
    
    var_dump($calendar);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a fairly mundane piece jQuery that toggles a div's visibility when a
I'm including a local class that requests a file from a remote server. This
I'm trying to create a parser (with parsec), that parses tokens, delimited by newlines,
This is an interesting problem that I have searched here and all over my
I'm trying to generate the complete sentence in which a word was highlighted using
So to start, I have an array of XML files. These files need to
I recently ran against a very interesting site that expresses a very interesting idea
I'm creating a FORM with PHP for an intranet webpage. Another PHP script is
I'm trying to create a chrome extension and im doing this by parsing an
I have set of xml elements like this: <item code=<HTML_CODE> /> For example: <items>

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.