Jump to content

changing array names, and splitting intigers and strings using regex. helpneeded


boo_lolly

Recommended Posts

i'm pretty sure this is fairly simple. i am working with a third party shopping cart and integrating an API (yourpay.com). the problem is the order array variables in the shopping cart are not recognized by yourpay.com. i need to change the variable names after they've been inputted into our database so the order information (name, total price, credit card number, address, that kind of stuff) can be sent to yourpay.com with variable names which its api can recognize. i'm pretty sure it goes something like this. at the end of the form...
[code]
<?php
//example
    orderarray('name1' => 'name2', 'address1' => 'address2', 'ccnumber1' => 'ccnumber2', 'ccexpiration1' => 'ccexpiration2');
?>
[/code]
am i doing this correctly? i believe that is how it's done. then THOSE variables are sent to yourpay.com. here's the real problem though. in the shopping cart address field, the entire variable is set as a string (numbers AND street name). yourpay.com does it differently. it retrieves the number address as an intiger, then it retrieves the name of the address as a string. what function could i use to grab the [i]first[/i] numbers found in the address string (until it reaches a character), and name those numbers (by themselves) as a variable in the orderarray? AND send the string address (name of street) to the string address variable in the array? the reason why i can't use a function to grab [i]all[/i] the intigers is because of apartment numbers. if the purchaser lives in an apartment, he/she will write the apartment number [i]after[/i] the street name. so, it must be only the FIRST intigers found in the address field. i think this can be done with the split functions, correct? something like...
[code]
<?php
    ($addrNum, $addrName) = (split(" ", $fullAddress);
?>
[/code]
something like that i think. obviously i have no experience (yet) with regex in php. but basically, i want the code to recognize where the first 'space' is in the address field. take everything [i]before[/i] the space and refer to it as $addrNum. everything [i]after[/i] the 'space' and refer to it as $addrName. if i understand correctly, $fullAddress is the string upon which the split function performs this command, right? i need help. fast. thanks in advanced =)

-boo
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.