<?php

/* init in costruct */
function getCountry()    { return 'Country';     }
function getRegion()     { return 'Region';      }
function getCity()       { return 'City';        }
function getZipCode()    { return 'ZipCode';     }
function getStreet()     { return 'Street';      }
function getHouseNumber(){ return 'HouseNumber'; }
function getBuilding()   { return 'Building';    }
function getAppartment() { return 'Appartment';  }

/* init in costruct */
$func = array(
'country'     => array('getCountry',     'Customer address info: ' ),
'region'      => array('getRegion',      ', ' ),
'city'        => array('getCity',        ', ' ),
'zipCode'     => array('getZipCode',     ', ' ),
'street'      => array('getStreet',      ', ' ),
'houseNumber' => array('getHouseNumber', ', ' ),
'building'    => array('getBuilding',    ', корп. ' ),
'appartment'  => array('getAppartment',  ', кв. ' )
);

function getAddresInfo($cfg)
{
	global $func; 
	$CustomerAddrInfo = '';

	foreach ($cfg as $key=>$val) {
		if ($val == '1') 
			$cfg[$key] = $func[$key][0]();

		$CustomerAddrInfo .= (!empty($cfg[$key]))? $func[$key][1] . $cfg[$key] : '';
	}
	return $CustomerAddrInfo;
}

/* config argument for getAddresInfo($cfg) */
$addressInfo = array(
'country'     => '1',
'region'      => '1',
'city'        => '1',
'zipCode'     => '1',
'street'      => '1',
'houseNumber' => '1',
'building'    => '1',
'appartment'  => '1'
);

echo getAddresInfo($addressInfo);
$addressInfo['appartment'] = '0';
echo "\n";
echo getAddresInfo($addressInfo);
echo "\n";
$addressInfo['building'] = '0';
echo getAddresInfo($addressInfo);
?>