|
|
|
| Title : |
Banknote Validation - A PHP class that provides several methods to quickly validate banknote serial numbers of the following currencies: AUD, CAD, CHF, CNY, EUR, GBP, JPY, USD.
|
| Categories : |
PHP, PHP Classes, Data Validation, Regexps |
 Alix Axel |
| Date : |
Apr 28th 2009 |
| Grade : |
3 of 5 (graded 1 times) |
| Viewed : |
1709 |
| File : |
No file for this code example. |
| Images : |
No Images for this code example. |
|
| Search : |
More code by Alix Axel |
|
| Action : |
Grade This Code Example
|
|
| Tools : |
My Examples List |
|
|
|
|
|
|
|
Like this code?
Show the author your appreciation.
|
|
| |
|
<?php
class Is_Banknote
{
function AUD($string)
{
if (preg_match('~^[a-z]{2}\d{8}$~i', $string) > 0)
{
return true;
}
return false;
}
function CAD($string)
{
if (preg_match('~^[a-z*]?[a-z]{2}\d{7}$~i', $string) > 0)
{
return true;
}
return false;
}
function CHF($string)
{
if (preg_match('~^\d{2}[a-z]\d{7}$~i', $string) > 0)
{
return true;
}
return false;
}
function CNY($string)
{
if (preg_match('~^[a-z]{1,2}(?:\d{6}|\d{8})$~i', $string) > 0)
{
return true;
}
return false;
}
function EUR($string)
{
if (preg_match('~^[a-z]\d{11}$~i', $string) > 0)
{
return true;
}
return false;
}
function GBP($string)
{
if (preg_match('~^[a-z]{2,3}\d{6,7}$~i', $string) > 0)
{
return true;
}
return false;
}
function JPY($string)
{
if (preg_match('~^[a-z]{1,2}\d{6}[a-z]$~i', $string) > 0)
{
return true;
}
return false;
}
function USD($string)
{
if (preg_match('~^[a-z]?[a-l]\d{8}[a-np-z*]$~i', $string) > 0)
{
return true;
}
return false;
}
}
?> | |
Usage:
| <?php
var_dump(Is_Banknote::AUD('serial number here'));
var_dump(Is_Banknote::CAD('serial number here'));
var_dump(Is_Banknote::CHF('serial number here'));
var_dump(Is_Banknote::CNY('serial number here'));
var_dump(Is_Banknote::EUR('serial number here'));
var_dump(Is_Banknote::GBP('serial number here'));
var_dump(Is_Banknote::JPY('serial number here'));
var_dump(Is_Banknote::USD('serial number here'));
?> | | |
|
| Power Form Validation Categories : PHP, PHP Classes, Data Validation | | | Validating a URL with preg_match Categories : PHP, Regexps, Beginner Guides, Data Validation | | | Db_lib - practical example usage of database abstraction and form validation.
Categories : PHP, Form Processing, PHP Classes, Data Validation, Beginner Guides | | | PHP Image Validation Class - test if a specific file is of a certain image type without relying on the said file extension. Categories : PHP, PHP Classes, Data Validation, Graphics, Beginner Guides | | | EAvalidator - This class can be used to validate an e-mail address by checking its domain. Categories : PHP, PHP Classes, Email, Regexps | | | The GTV.class allows you to extract a value between any HTML tag or between any TEXT on a web page. Categories : PHP, PHP Classes, Regexps | | | FormChecker Package - validate any data via classes and patterns.
Categories : PHP, Form Processing, PHP Classes, Regexps | | | Form is a utility class for generating html forms. It provides form initialization and regex based data validation (both server and client side) with a convenient interface. This version obsoletes version 1.0a Categories : HTML, PHP, PHP Classes, Regexps | | | YellowPages Content Grabber (PHP5 +) Categories : PHP, PHP Classes, Regexps, Databases, MySQL | | | Validator - A PHP class that can can be used for validating Email IDs and Dates Categories : PHP, PHP Classes, Data Validation, Email, Date Time | | | Parsing Simple Template Files and Data Categories : PHP, PHP Classes, Templates, Regexps | | | Check for functional file links (broken Files)
Categories : PHP, Data Validation, FTP, Regexps, Arrays | | | An array of functions to use in checking user input to HTML forms : text, firstName, middleNameOrInit, lastName, email, web, digits, decimal, hex, genNum, USD, BPS, Euro, USphone, USzip Categories : PHP, Data Validation, Regexps | | | making links from text Categories : PHP, Regexps, Email | | | Automatic Browsers Detect Categories : PHP, PHP Classes, Headers, Browsers | |
|
|