WooParc_split_address

Split address into street, housenumber and extension.

Description

WooParc_split_address( $address ); 

Parameters (1)

0. $address
The address.

Usage

  1. if ( !function_exists( 'WooParc_split_address' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'woocommerce-postnl-parcelware/inc/funct-export.php'; 
  3.  
  4. // The address. 
  5. $address = null; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = WooParc_split_address($address); 
  9.  

Defined (1)

The function is defined in the following location(s).

/inc/funct-export.php  
  1. function WooParc_split_address($address) { 
  2. if ( preg_match( '~^[0-9]+, ~', $address ) ) 
  3. $pattern = '#^([0-9], ) ([\p{L}a-z0-9\-/ \']*) ([\p{L}a-z0-9\-/ ]{0, })#i'; 
  4. $b = preg_match($pattern, $address, $aMatch); 
  5. $huisnummer = (isset($aMatch[1])) ? $aMatch[1] : ''; 
  6. $straatnaam = (isset($aMatch[2])) ? $aMatch[2] : ''; 
  7. $huisnrtoe = (isset($aMatch[3])) ? $aMatch[3] : ''; 
  8. else 
  9. $pattern = '#^([\p{L}a-z0-9 [:punct:]\']*) ([0-9 ]{1, 5})([\p{L}a-z0-9\-/]{0, })$#i'; 
  10. $aMatch = array(); 
  11. $b = preg_match($pattern, $address, $aMatch); 
  12. $straatnaam = (isset($aMatch[1])) ? $aMatch[1] : ''; 
  13. $huisnummer = (isset($aMatch[2])) ? $aMatch[2] : ''; 
  14. $huisnrtoe = (isset($aMatch[3])) ? $aMatch[3] : ''; 
  15. if($straatnaam!="" && $huisnummer!="") { 
  16. return array ($straatnaam, $huisnummer, $huisnrtoe); 
  17. } else { 
  18. return false;