Skip to content

Commit

Permalink
Merge pull request #1 from travisulrich/patch-1
Browse files Browse the repository at this point in the history
Add parameter to allow for removal of blank lines
  • Loading branch information
adamlc committed Mar 24, 2014
2 parents 7759377 + c986f7b commit 10dc4cd
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/Adamlc/AddressFormat/Format.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,10 @@ public function setLocale($locale)
*
* @access public
* @param bool $html (default: false)
* @param bool $condensed (default: false)
* @return void
*/
public function formatAddress($html = false)
public function formatAddress($html = false, $condensed = false)
{
//Check if this locale has a fmt field
if (isset($this->locale['fmt'])) {
Expand All @@ -103,6 +104,11 @@ public function formatAddress($html = false)
foreach ($this->address_map as $key => $value) {
$formatted_address = str_replace('%' . $key, $this->input_map[$value], $formatted_address);
}

//Optionally remove blank lines from the resulting address
if ($condensed){
$formatted_address = preg_replace('([\%n]+)', '%n', $formatted_address);
}

//Replace new lines!
if ($html) {
Expand Down

0 comments on commit 10dc4cd

Please sign in to comment.