parsing strings
Posted: Mon Dec 26, 2011 11:54 pm
Hello forum, I'm here looking for some help. I've searched through the internet looking for how to parse a config file. I have a file that looks like the following:
MAX_PLAYERS = 100
ENABLE_SPELLS = TRUE
I would like to read this from a file named test.cfg and set the values into variables. So far I have this :
Im able to get the strings, but unable to parse the string into getting the data and setting it into the variables $MAX_PLAYERS and $ENABLE_SPELLS
MAX_PLAYERS = 100
ENABLE_SPELLS = TRUE
I would like to read this from a file named test.cfg and set the values into variables. So far I have this :
Code: Select all
<?php
$file = fopen("test.cfg","r");
if(file != NULL)
{
while(!feof($file))
{
$line = fgets($file);
//im stuck here on parsing it
}
}
?>