I have a data file in the following format.
// sample data
param1 "value of param1"
param2 0
param3 1
I am currently using the following code to read the data but it won't read all the data of quoted values. I didn't put the fopen stuff in the example.
while(!feof($fp))
{
$line = fgets($fp, 4096);
if (!ereg("^/\/\.*", $line) && trim($line) != "")
{
list($key, $value) = preg_split ("/[\s]+/", $line);
echo $key . ' = ' . $value . '<br>';
}
}
What I get returned is:
param1 = "value
param2 = 0
param2 = 1
The problem lies in that I am not getting back all the data between quotes. What can I do? Also, preg_split was just another attempt at fixing the problem. I've also used sscanf.
Thanks in adavance,