hypervisor
asked on
preg_match with php for credit card info from magnetic stripe reader
Hello, I'm trying to use the following code to extract the data elements from a magnetic stripe credit card (fake information provided, obviously) - the preg_match is correct, but it's not returning results - I'm a little unfamiliar with this function, so any help would be appreciated:
<?php
$creditcard = "%B0000111122224444^JACKSON/JANE^1201201100001100000000621000000?";
$swipe = "/^(%B)([0-9]{16})(^)([a-zA-Z-s]*)(/)([a-zA-Z-s]*)(^)([0-9]{2})([0-9]{2})(.)*?$/";
preg_match($swipe, $creditcard, $matches);
echo "<br><br>Credit card details<br>";
$card = $matches[2];
$firstname = $matches[6];
$lastname = $matches[4];
$exp = $matches[9]."".$matches[8];
echo $card;
echo $firstname;
echo $lastname;
echo $exp;
?>
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Please help me understand if there was something wrong with my solution. What did you not understand about it? Did you try the code and find it unworkable for some reason?
http://iconoun.com/demo/temp_hypervisor.php
Open in new window