Skip to content

Instantly share code, notes, and snippets.

@morgyface
Created April 2, 2020 10:40
Show Gist options
  • Select an option

  • Save morgyface/71d032b1b45278a4987bc3228292e8c4 to your computer and use it in GitHub Desktop.

Select an option

Save morgyface/71d032b1b45278a4987bc3228292e8c4 to your computer and use it in GitHub Desktop.
PHP | Function | Convert UK shoe size to EU
<?php
// Convert UK shoe size to European size
function euro_shoe( $uk_size ) {
$eu_size = null;
if( ! is_numeric( $uk_size ) ) {
return $eu_size; // Abort if we are NOT dealing with a number
}
if ( in_array($uk_size, range(2, 19, 0.5)) ) {
// Check to make sure it is a sensible shoe size number using a range with half size steps
// Now work through the equation
$eu_size = $uk_size + 23;
$eu_size = 1.27 * $eu_size;
$eu_size = $eu_size + 2;
$eu_size = round($eu_size); // Lets round to whole number
}
return $eu_size;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment