Share Pastebin
Guest
Public paste!

Palocz Pal

By: a guest | Feb 7th, 2010 | Syntax: PHP | Size: 1.05 KB | Hits: 84 | Expires: Never
Copy text to clipboard
  1. <?php
  2. // $Id: zipcode.hu.inc,v 1.9 2009/08/26 16:32:02 thierrygd Exp $
  3.  
  4. // Copyright 2008 Thierry GUEGAN http://www.arvoriad.com
  5.  
  6. /**
  7.  * @file
  8.  * CCK Field for Hungarian zipcodes.
  9.  */
  10.  
  11. /**  
  12.  * Verification for Hungarian zipcodes.  
  13.  *
  14.  * @param string $text
  15.  * @return boolean Returns boolean FALSE if the zipcode is not valid.
  16.  * On success, returns a string containting the zipcode with some formatting.
  17.  */
  18. function valid_hu_zipcode($zipcodestring) {
  19.   $zipcodestring = trim($zipcodestring);
  20.  
  21.   if (!preg_match("/(^\d{4}$)/",$zipcodestring)) {
  22.         return FALSE;
  23.   }
  24.   //right now just do a quick check ==> has to be improved
  25.   //need to check more precisely by doing a query on a zipcode table, ...
  26.   else
  27.   {
  28.         return TRUE;
  29.   }
  30. }
  31.        
  32. /**
  33.  * Formatting for zipcode.  
  34.  *
  35.  * @param string $zipcodestring
  36.  * @return string Returns a string containting the zipcode with some formatting.
  37.  */
  38. function format_hu_zipcode($zipcodestring) {
  39.  
  40.   $zipcodestring = trim($zipcodestring);
  41.   //do some formatting
  42.   return $zipcodestring;
  43. }