Created
August 16, 2017 10:52
-
-
Save carschrotter/905f98ea70246b5f8a6e4d3cfd255f2d to your computer and use it in GitHub Desktop.
This file contains 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 | |
/** | |
* Removed the house number from a german like address | |
* @param string $street | |
* @return string | |
*/ | |
function removeHouseNumber($street) { | |
// removes the last occurrence of a house number type specification: 12. Februar-Platz 1A = 1A | |
//entfernt letztes vorkommen einer Hausummerntypischen Angabe: 12. Februar-Platz 1A = 1A | |
return \preg_replace('/([0-9\\-\\/ ]+?[a-z]?)$/i', '', $street); | |
} | |
//Example: | |
//find streetname | |
echo removeHouseNumber('12. Februar-Platz 1A'); // 12. Februar-Platz | |
//find housnumber | |
echo trim(str_replace(removeHouseNumber('12. Februar-Platz 1A'))) // 1A |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment