CoderZone.org

Category: >> PHP Code >> Add dashes to credit card numbers Bookmark and Share

<< lastnext >>

Snippet Name: Add dashes to credit card numbers

Description: Easily add dashes to credit card numbers.

Comment: (none)

Author: CoderZone
Language: PHP
Highlight Mode: PHP
Last Modified: March 01st, 2009

<? php
 
function AddDash($CC_Num,$CC_Type){ 
if ($CC_Type="VISA") { 
$NewCC=""; 
for ($i=0 ; $i < 4 ; $i++) 
$NewCC=$NewCC.substr($CC_Num, ($i*4), 4)."-"; 
} 
$NewCC=substr($NewCC,0,19); 
return ($NewCC); 
} 
 
// Example : 
 
$new_cc_num=AddDash("4580458045804580","VISA"); 
echo"$new_cc_num"; 
 
?>
 
 
There haven't been any comments added for this snippet yet. You may add one if you like.  Add a comment 
© coderzone.org | users online: 4