pmpro_formatAddress

Format an address from address, city, state, zip, country, and phone.

Description

pmpro_formatAddress( (string) $name, $address1, $address2, $city, $state, $zip, (number) $country, $phone, (constant) $nl2br = true ); 

Parameters (9)

0. $name (string)
The name.
1. $address1
The address1.
2. $address2
The address2.
3. $city
The city.
4. $state
The state.
5. $zip
The zip.
6. $country (number)
The country.
7. $phone
The phone.
8. $nl2br — Optional. (constant) => true
The nl2br.

Usage

  1. if ( !function_exists( 'pmpro_formatAddress' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'paid-memberships-pro/includes/functions.php'; 
  3.  
  4. // The name. 
  5. $name = ''; 
  6.  
  7. // The address1. 
  8. $address1 = null; 
  9.  
  10. // The address2. 
  11. $address2 = null; 
  12.  
  13. // The city. 
  14. $city = null; 
  15.  
  16. // The state. 
  17. $state = null; 
  18.  
  19. // The zip. 
  20. $zip = null; 
  21.  
  22. // The country. 
  23. $country = null; 
  24.  
  25. // The phone. 
  26. $phone = null; 
  27.  
  28. // The nl2br. 
  29. $nl2br = true; 
  30.  
  31. // NOTICE! Understand what this does before running. 
  32. $result = pmpro_formatAddress($name, $address1, $address2, $city, $state, $zip, $country, $phone, $nl2br); 
  33.  

Defined (1)

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

/includes/functions.php  
  1. function pmpro_formatAddress($name, $address1, $address2, $city, $state, $zip, $country, $phone, $nl2br = true) 
  2. $address = ""; 
  3.  
  4. if(!empty($name)) 
  5. $address .= $name . "\n"; 
  6.  
  7. if(!empty($address1)) 
  8. $address .= $address1 . "\n"; 
  9.  
  10. if(!empty($address2)) 
  11. $address .= $address2 . "\n"; 
  12.  
  13. if(!empty($city) && !empty($state)) 
  14. $address .= $city . ", " . $state; 
  15.  
  16. if(!empty($zip)) 
  17. $address .= " " . $zip; 
  18.  
  19. $address .= "\n"; 
  20.  
  21. if(!empty($country)) 
  22. $address .= $country . "\n"; 
  23.  
  24. if(!empty($phone)) 
  25. $address .= formatPhone($phone); 
  26.  
  27. if($nl2br) 
  28. $address = nl2br($address); 
  29.  
  30. return apply_filters('pmpro_formatted_address', $address, $name, $address1, $address2, $city, $state, $zip, $country, $phone, $nl2br );