<?php
// top of page

	$top_content = "";
	$fh1 = fopen('top.php','r');
	while(!feof($fh1))
	{
		$top_content .= fgets($fh1);
	}
	fclose($fh1);
	
// bottom of page

	$bot_content = "";
	$fh_country = fopen('bottom.php','r');
	while(!feof($fh_country))
	{
		$bot_content .= fgets($fh_country);
	}
	fclose($fh_country);

	
// Create pages	
	$file_handle = fopen('separate-regions.csv', 'r');
	$country_content = "";

	while(!feof($file_handle)) 
	{
		$line = fgetcsv($file_handle, 1024);
		$city 	= $line[0];
		$code	= $line[1];
		$city_all = $line[2];
		$city_link = '/numbers/0'.$code.'-'.strtolower(str_replace("- ","",str_replace(" ","-",str_replace("(","",str_replace(")","",$city))))).'-uk-numbers.php';
		$add_line = '<a href="'.$city_link.'">'.$city_all.'</a><br/>';
		
		$country_content .= $add_line."\n";		
	}
	fclose($file_handle);
	
	$full_content = $top_content.$country_content.$bot_content;
	$country_file = '/home/fdesign1/public_html/phone-numbers-uk.com/numbers/uk-regional-numbers.php';
	
	if ($handle_country = fopen($country_file,'w'))
	{
		fwrite($handle_country,$full_content);
		fclose($handle_country);
	}
	echo 'Done';
?>