Category: PHP

Custom Zend Validator for Localized Numbers

When dealing with i18n web applications the need to support localized number representations becomes obvious. Thus, users should be able to enter localized numbers such as “1.000.50 $” when for instance using the locale en_US or “1,000.50 $” when using de_AT. Now, when it comes to validating user input throughZend_Form Zend provides special validators to […]

Mehrseitige Formulare mittels Zend Framework umsetzenImplementing multi-page forms using the Zend Framework

Unfortunately, the Zend Framework (ZF) version 1.x currently does not provide a standard way or class to implement multi-page forms based on Zend_Form. Due to the fact that this is a very common use case I will try to explain a working solution to overcome this problem. Basically, the goal is to provide means to […]

Liste der von Google Currency Converter unterstützten Währungen (ISO-4217 Codes)List of currencies supported by Google currency converter (ISO-4217 codes)

The following is a list of ISO-4217 currency codes supported by Google’s currency converter available at After some research this list includes all of the most commonly used currencies world-wide (please leave a comment if you find any errors or missing entries). Thus. it can be used as a template for currency selection drop-downs, […]

Parsing der Google Currency JSON Antwort als PHP ArrayParse Google Currency JSON response as PHP array

Unfortunately Google’s currency converter ( does not return JSON data that can be directly parsed by PHP’s json_decode as its keys are not enclosed in (double) quotes. For instance, the following call to will return something like the following depending on the current conversion rate: Thus, the keys lhs, rhs, error and icc are […]

Währungsumrechnung mit Zend_Currency und Anzeige des korrekten WährungssymbolsCurrency conversion using Zend_Currency and displaying correct currency symbols

When developing i18n’ed (web) applications it is important to keep various required conversions in mind, such as currency conversions when dealing with payments. In the case of the Zend Framework (ZF) this conversion can be done using Zend_Currency and optionally a conversion service based on the Zend_Currency_CurrencyInterface. One confusing thing when it comes to dealing […]

Text mit variabler Anzahl an Platzhaltern mittels Zend_Translate übersetzenTranslate text based on variable number of placeholders using Zend_Translate

In case you are wondering how to quickly translate text using Zend_Translate and variable numbers of placeholders here is a quick solution that uses built-in PHP funtionality: vsprintf to the rescue! First setup Zend_Translate to your needs, e.g. in Bootstrap: This configuration uses a gettext to parse translation files. Then in order to translate text […]

Mittels Zend_Date Monatsbereich berechnenDetermine month range using Zend_Date

The following function can be used to determine a range of days for a particular month, optionally based on a start and end date. This function comes handy for cron jobs, etc. Please refer to for an explanation of the constants MYSQL_DATETIME and MYSQL_DATE.

Delete/copy directories recursively using PHP

As there currently does not exist a PHP function that allows developers to delete or copy entire (non-empty) directories at once one has to recursively loop through them to manually delete/copy their contents. This post provides you with two easy to use functions for deleting entire (non-empty) directories copying entire (non-empty) directories First, let’s start […]

Zeitsynchronisation von Zend_Date mittels Zend_TimeSync und mehrerer TimeserverSynchronizing Zend_Date using Zend_TimeSync and multiple time servers

This post describes a simple approach to implement time synchronization using Zend_TimeSync for Zend_Date using multiple time servers. First of all you will need to create a new Zend_TimeSync instance, specifying a list of possible time servers. You may use the server pool provided by for this purpose. In case you specifiy multiple servers […]

Automatische Größenanpassung von Bildern mit TCPDFAuto-fit images onto current page using TCPDF

Recently I had to fit images onto the current page of a dynamically generated PDF document using the functionality provided by the (superb) TCPDF toolkit. Due to the fact that I had to include HTML content in the PDFs I was bound to use the writeHTML function. The HTML content was basically structured using plain […]

Access protection using Apache’s .htaccess and PHP

Sometimes it is necessary to limit access to certain files and folders based on your own PHP backend authentication script, i.e. you cannot use Apache’s built-in user authentication, but rather rely on backend authentication provided by your PHP framework. The following script demonstrates a simple approach to realize access protection using a .htaccess file in […]