How do you take a string seperated by commas and seperate them into seperate variables and fields?

For example, I want to take a returned string of..

1,1,1,0,1,1,1

and change it into data readable such as

if postion 1 = 1 then transaction = Approved.

Any info appreciated.

Rab

    $string = '1,1,1,0,1,1,1';
    $array = explode (',', $string);
    foreach ($array as $key => $value)
    {
    if ($value) {$status = 'Approved';} else {$status = 'Declined';}
    echo "position $key = $status<br>";
    }
    

      I need to clarify, position 1 can be a 1,2 or 3. For example 2,3,1 with each number being a different value where 1 is approved, 2 is declined and 3 is error. I also need to take other text, thats seperate by commas, and turn that into something understandable also.

      It's a string that looks like this...

      1,1,1,This transaction has been approved.,000000,P,0,,,100.00,CC,auth_capture,,,,,,,,,,,,,,,,,,,,,,,,,,

      This string is generated from submitted a credit card transaction to authorize.net.

      Authorize.net has very very little information on submitting this info and returning the values through PHP.

      I'm at a crossroads here, dump PHP and use cgi or ASP for the transactions is my only alternative.

      Rab

        Actually Authorize.net has ALOT of information in thier implementation guide.
        The data they return is predefined fields so just use list() to assign values to variables and use the explode previously suggested, the rest is up to you as to how you want to handle the meaning of the values...but seriously dig around thier site there are some great charts of all the info you're looking for.
        I'd give you a link but it's all post login on thier site.
        I had to write an interface recently, but I used relay response and from what you're posting you are using direct connect. But it's all therei n the guides.
        (not specific to PHP but enough to do it in any lang)

        -Mce

          Write a Reply...