bend and dvd2mkv

I’ve been working on bend a lot lately (my PHP script to rip DVDs), and am taking a break to work on a different script — dvd2mkv.

dvd2mkv will basically be a somewhat interactive PHP script to rip a DVD, do a two-pass encode and dump the whole thing into a Matroska file.

Anyway, working on it the other day I got some code working so I could have a .bendrc file in normal rc file fashion, that is param=value, and wrote a function parse it too. Here’s that:

function parseConfigFile($file) {
$readfile = file($file);
$readfile = preg_grep(’/^\w+=(\w|\/)+$/’, $readfile);

foreach($readfile as $key => $value) {
$arr_split = preg_split(’/\s*=\s*/’, $value);
$arr_config[trim($arr_split[0])] = trim($arr_split[1]);
}

return $arr_config;
}

Leave a Reply