$val) { $safe = true; //primary parsing: removing blank lines and stripping comments $val = trim($val); $tmpval = explode('#', $val); $val = trim($tmpval[0]); if($val == "") { continue; } //now parse for foo(bar|baz) if(preg_match('/\([^)]+\)/', $val)) { preg_match_all('/\(([^)]+)\)/', $val, $vlist); $val = preg_replace('/\([^)]+\)/', '', $val); foreach($vlist[1] as $vval) { $xlist = explode("|", $vval); foreach($xlist as $xval) { $newlist[] = $val.trim($xval); } } $safe = false; } if($safe) $newlist[] = $val; } $list = &$newlist; unset($newlist); foreach($list as $site) { $ips = gethostbynamel($site); if($ips === false) continue; foreach($ips as $ip) { file_put_contents('output.txt', "$site=$ip\n", FILE_APPEND); echo "$site=$ip\n"; } } echo "***DONE\n"; ?>