Possible Duplicate:
Converting ereg expressions to preg
I am totally new to parsing a cfg file to php. Still tried to search couple of website and i found this exmaple. But it has some errors in it. I dont understand how can i solve them.
I have a .cfg file named my_config.cfg
. It has the information as shown below.
# ATA/IDE/MFM/RLL support
#
CONFIG_IDE=y
#
# IDE, ATA and ATAPI Block devices
#
CONFIG_BLK_DEV_IDE=y
CONFIG_BLK_DEV_IDEDISK=y
CONFIG_BLK_DEV_IDECD=n
I am trying to parse it in php.
Code:
<?php
$config_file = "my_config.cfg";
$comment = "#";
$fp = fopen($config_file, "r");
while (!feof($fp)) {
$line = trim(fgets($fp));
if ($line && !ereg("^$comment", $line)) {
$pieces = explode("=", $line);
$option = trim($pieces[0]);
$value = trim($pieces[1]);
$config_values[$option] = $value;
}
}
fclose($fp);
if ($config_values['CONFIG_IDE'] == "y")
echo "CONFIG_IDE is set<br />";
else
echo "CONFIG_IDE is not set<br />";
?>
But I am getting error:
Deprecated: Function ereg() is deprecated in C:\xampp\htdocs\test.php on line 9
CONFIG_IDE is set<br />
Any Solutions???