Avatar of Member_2_5212910
Member_2_5212910
Flag for United Kingdom of Great Britain and Northern Ireland asked on

Parsing Configuration File

Please show an example of how I can parse this file into an array in PHP. The ideal output would be the equivalent of making this array (not all values are shown in the example):

array("unlocks" => array(
 "Sprint_Mki" => "1",
 "Sprout_Collect" => "1"
),
"experience" => array(
 "Lumbering" => "36"
));

NB: The configuration file will change to have more values in and the script must accommodate for these changes.
"Out"
{
	"unlocks"
	{
		"Sprint_Mki"		"1"
		"Sprout_Collect"		"1"
		"Grain_Planting"		"1"
		"Sprout_Planting"		"1"
	}
	"experience"
	{
		"Lumbering"		"36"
		"Planting"		"24"
		"Survival"		"0"
		"Mining"		"0"
		"Harvesting"		"24"
		"Weapon_Crafting"		"0"
	}
	"date"		"Monday 02/22/10"
	"skills"
	{
		"Lumbering"		"8"
		"Planting"		"6"
		"Survival"		"6"
		"Mining"		"8"
		"Harvesting"		"6"
		"Weapon_Crafting"		"2"
	}
	"name"		"James"
}

Open in new window

PHP

Avatar of undefined
Last Comment
Member_2_5212910

8/22/2022 - Mon
Ray Paseur

Are you sure you want an array?  It looks more like an object pattern to me.  Where does this file come from?
ASKER CERTIFIED SOLUTION
Member_2_5212910

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
Your help has saved me hundreds of hours of internet surfing.
fblack61