收集了一些方法,用来生产域名然后查询注册信息。

= count($data)) {
		array_push($all, $group);
	}
	else {
		$currentKey     = $keys[$i];
		$currentElement = $data[$currentKey];
		foreach ($currentElement as $val) {
			generate_combinations($data, $all, $group, $val, $i + 1);
		}
	}
	
	return $all;
}

function cartesian_product($a) {
	$result = array(array());
	foreach ($a as $list) {
		$_tmp = array();
		foreach ($result as $result_item) {
			foreach ($list as $list_item) {
				$_tmp[] = array_merge($result_item, array($list_item));
			}
		}
		$result = $_tmp;
	}
	return $result;
}

function get_combinations($arrays) {
	$result = array(array());
	foreach ($arrays as $property => $property_values) {
		$tmp = array();
		foreach ($result as $result_item) {
			foreach ($property_values as $property_value) {
				$tmp[] = array_merge($result_item, array($property => $property_value));
			}
		}
		$result = $tmp;
	}
	return $result;
}


$data = array(
    range('a', 'z'),
    range('a', 'z'),
    range('a', 'z'),
    range('a', 'z'),
    range('a', 'z'),
);


$combos = generate_combinations($data);
echo sizeof($combos);
echo "\n";
echo "not real: ".(memory_get_peak_usage(false)/1024/1024)." MiB\n";
echo "real: ".(memory_get_peak_usage(true)/1024/1024)." MiB\n\n";

标签: none

添加新评论