...

View Full Version : help with Regular Expressions



barkermn01
03-10-2009, 10:02 PM
i am trying to build a system using a config file

but i'm not sure on how to read the files


function read_pram($pram, $fail = null){ // read saved settings - for child instance to load settings
$fh = fopen('deamon.ini', 'r');
$buf = '';
while(!feof($fh)){// at end of file?
$buf .= fread($fh, 512); // read till end of file
}// end of file reached
fclose($fh);
$result = preg_match("[".$pram."]=(.*?)\n", $buf);
if($result == 'NULL'){// result not returned?
return $fail;
}// result was returned
return $result;
}//end read


Im not sure about this line
$result = preg_match("[".$pram."]=(.*?)\n", $buf);

is it preg_match the right way if not can some one show me please

Iszak
03-10-2009, 11:37 PM
parse_ini_file (www.php.net/parse_ini_file)



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum