PHP code question

holdeN

Limp Gawd
Joined
Mar 15, 2002
Messages
258
Hey guys. I'm trying to program CC processing for my website and am having some trouble figuring out the best way to do this one part. If anyone can give me some code for this... I'll paypal 20 bucks or so :) (If this isn't allowed... nm!)

Basically, I get a response from the cc processor server as one variable. Something like this:

"YAUTH/TKT 140397","AVS Match 5 Digit Zip and Address (y)","","11","20070425131843-1206183-11","RecurID=15"

I need that string broken up so I can manipulate the different vars. And within the first var I need it broken up even more. I'll just show you what I need the outcome to be....

var1 = Y
var2 = AUTH/TKT 140397
var3 = AVS Match 5 Digit Zip and Address (y)
var4 =
var5 = 11
var6 = 20070425131843-1206183-11
var7 = 15 (Notice "RecurID =" is left out!)

Any takers? :D
 
Hey guys. I'm trying to program CC processing for my website and am having some trouble figuring out the best way to do this one part. If anyone can give me some code for this... I'll paypal 20 bucks or so :) (If this isn't allowed... nm!)

Basically, I get a response from the cc processor server as one variable. Something like this:

"YAUTH/TKT 140397","AVS Match 5 Digit Zip and Address (y)","","11","20070425131843-1206183-11","RecurID=15"

I need that string broken up so I can manipulate the different vars. And within the first var I need it broken up even more. I'll just show you what I need the outcome to be....

var1 = Y
var2 = AUTH/TKT 140397
var3 = AVS Match 5 Digit Zip and Address (y)
var4 =
var5 = 11
var6 = 20070425131843-1206183-11
var7 = 15 (Notice "RecurID =" is left out!)

Any takers? :D

Can't you just explode it using a comma as the delimiter and parse the individual pieces as necessary?
 
Code:
$blah = explode( $string, "," );

foreach( $blah as $key => $val )
{
  $blah[$key] = trim( $val, '" ' );
}

$var1 = substr( $blah[0], 0, 1 );
$var2 = substr( $blah[0], 1 );
$var3 = $blah[1];
$var4 = $blah[2];
$var5 = $blah[3];
$var6 = $blah[4];
$var7 = intval( substr( $blah[5], 8 ) );
Yeh, im bored.....:rolleyes:
 
Cool. Thanks Xeth. You saved me some time from playing around on php.net :D

PM me your email addy if you want some paypal cash flow.
 
Back
Top