Roman Conversion

<?php

$lines = file('http://hyperspatial.com/romans.txt');
//$lines = array('MM','IX','X');
$array_of_converted_values = array();

foreach($lines as $line_num => $line) $array_of_converted_values[] = convert_roman_numeral(htmlspecialchars($line));

print_r($array_of_converted_values);

function convert_roman_numeral($roman_numeral = 'M'){
$roman_array = array('M' => 1000,'CM' => 900,'D' => 500,'CD' => 400,'C' => 100,'XC' => 90,'L' => 50,'XL' => 40,'X' => 10,'IX' => 9,'V' => 5,'IV' => 4,'I' => 1);
$result = 0;
foreach($roman_array as $key => $value) {
while(strpos($roman_numeral, $key) === 0) {
$result += $value;
$roman_numeral = substr($roman_numeral, strlen($key));
}
}
return $result;
}
?>

Parse Hyperlink

<?php
$line = '<a href="/users/adam">Edit profile</a>';
$converted_line = preg_replace('/<a[^>]*?href=['"](.*?)['"][^>]*?>(.*?)</a>/si','<a href="http://hyperspatial.com$1" target="_blank">$2</a>',$line);
echo $converted_line;
?>

Get Gravatar

<?php

function get_avatar($email){
$hash = md5(strtolower(trim($email)));
echo "<img src="http://www.gravatar.com/avatar/" . $hash . "?s=60">";
}

/* References
https://en.gravatar.com/site/implement/images/
https://en.gravatar.com/site/implement/hash/
*/

?>