$n) { preg_match('/^.{1,'.$n.'}\b/s', $str, $matches); return rtrim($matches[0]) ; } else { return $str; } } function format_price($amount, $currency) { if (null === $amount) { return null; } $currency = (string) $currency; switch(sfContext::getInstance()->getUser()->getCulture()) { case 'cs': $currency = 'CZK'; break; default: $currency = 'EUR'; break; } switch($currency) { case 'CZK': case 'EUR': // Desetinna mista pouze pokud je potreba $strm = floor($amount) != $amount ? '.00' : ''; $pattern = '#,##0'.$strm.' ¤'; break; default: $pattern = '#,##0.00 ¤'; break; } $numberFormat = new sfNumberFormat(sfContext::getInstance()->getUser()->getCulture()); return $numberFormat->format($amount, $pattern, $currency); }