// unify newlines to unix format $file=preg_replace('/[rn]+/', "n", $file); // get lines from file $lines=explode("n", $file); /* cvars array(3) 0 cvar name 1 cvar value 2 comment */ $cvars=array(); foreach($lines as $id => &$cvar){ $cvar=trim($cvar); if(substr($cvar, 0, 2)!='//' && preg_match('@(^w+) (("w+")|(w+)) ?(// ?(.*))?$@', $cvar, $matches)){ $cvars[]=array($matches[1], $matches[2], $matches[6]); } }