Created
April 2, 2020 10:40
-
-
Save morgyface/71d032b1b45278a4987bc3228292e8c4 to your computer and use it in GitHub Desktop.
PHP | Function | Convert UK shoe size to EU
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?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