[code]
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" 
   "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
	<title>Actuele Valuta Omrekener  -- Jason de Ridder</title>
</head>

<body>
	<p style="font-size: .9em">
		Koersen komen van 
		<a 	href="http://www.ecb.int/stats/eurofxref/eurofxref-daily.xml" 
			style="color:red;">
				The European Central Bank
		</a>
	</p>
	<h1>
		Bereken een actuele koers vanuit de &euro;<strong> EURO </strong>&euro;
	</h1>
	<p>
		Laatst bewerkt op:<br />
		<?php
		$xmlfile = file_get_contents('http://www.ecb.int/stats/eurofxref/eurofxref-daily.xml');
		preg_match("/Cube time=[\",'](.*)[\",']/i", $xmlfile, $pubdate);
		$pubdate = explode('-', $pubdate[1]);
		$pubdate = array_reverse($pubdate);
		$pubdate = implode('-', $pubdate);
		echo $pubdate.
	'</p>';
	$array_names = array(
					'Amerikaanse Dollar',
					'Japanse Yen',
					'Bulgaarse Lev',
					'Cyperse Pond',
					'Tjechiesche Kroon',
					'Deense Kroon',
					'Estlandse Kroon',
					'Engelse Pond',
					'Hongaarse Florijn',
					'Lithuanian Lats',
					'Letse Lats',
					'Maltese Lira',
					'Poolse Zloty',
					'Nieuw Romenese Leu',
					'Zweedse Kroon',
					'Slowaakse Kroon',
					'Zwitserse Frank',
					'Ijslandse Kroon',
					'Noorweegse Kroon',
					'Kroatse Kuna',
					'Russiche Roebel',
					'Nieuw Turkse Lieren',
					'Australische Dollar',
					'Canadese Dollar',
					'Chinese Yuan Renminbi',
					'Hong Kong Dollar',
					'Indonesische Rupiah',
					'Zuid Koreaanse Won',
					'Maleisische Ringgit',
					'Nieuw Zeelandse Dollar',
					'Filippijnse Peso',
					'Singaporese Dollar',
					'Thaise Baht',
					'Zuid Afrikaanse Rand'
				);
	?>
	<form action="" method="post">
		<fieldset>
			<legend>
				Bereken koers!
			</legend>
			<table summary="formholder">
				<tr>
					<td>&euro; <input type="text" name="waarde" value="<?php if(isset($_POST['waarde'])) { echo $_POST['waarde']; } else { echo '1,00'; } ?>" id="waarde" /></td>
				</tr>
				<tr>
					<td>
						<select name="currency">
							<?php
							echo '<option value=""'; 
							if(	!isset($_POST['currency']) ||
								empty($_POST['currency'])) {
									echo ' selected="selected"';
								}
							echo '>Maak hieronder uw keuze:</option>';
							echo "\n\t\t\t\t\t\t\t".'<option value="2.20371"';
							if(	isset($_POST['currency']) &&
								$_POST['currency'] == '2.20371') {
							  		echo ' selected="selected';
							}
							echo '>Nederlandse Gulden</option>';
							preg_match_all("/Cube currency=[\",'](.{3})[\",']/i", $xmlfile, $currency);
							preg_match_all("/Cube currency=[\",'].*[\",'] rate=[\",'](.*)[\",']/i", $xmlfile, $rate);
							foreach($currency[1] as $key => $valuta) {
									echo "\n\t\t\t\t\t\t\t".'<option value="'.$rate[1][$key].'"';
									if(	isset($_POST['currency']) &&
										$_POST['currency'] == $rate[1][$key]) {
									  		echo ' selected="selected"';
									}
									echo '>'.$array_names[$key].'</option>';
							}
							?>

						</select>
					</td>
				</tr>
				<tr>
					<td>
						<input type="submit" value="Bereken!" />
					</td>
				</tr>
			</table>
		</fieldset>
	</form>
	<?php
	if($_SERVER['REQUEST_METHOD'] === "POST") {
		$waarde = str_replace(',', '.', $_POST['waarde']);
		if(!is_numeric($waarde)) {
			echo '<p style="color:red;">Uw waarde is niet nummeriek!</p>';
		}
		else {
			if(	!empty($_POST['currency']) && 
				in_array($_POST['currency'], $rate[1])) {
					echo '<p style="font-size: 2em; color:blue;">';
					echo '&euro; '.$_POST['waarde'].
						 ' x '.str_replace('.',',', $_POST['currency']).
						 ' = <strong>'.
						 str_replace('.', 
						 			 ',', 
						 			 round(
						 			 	$_POST['waarde'] * $_POST['currency'], 
						 			 	2
						 			 )
						 			).
						 '</strong></p>';
			}
		}
	}
	?>
	
</body>
</html>
[/code]