searching through IPN string to get item_name for each item
Moderator: General Moderators
-
eoin.ahern@mycit.ie
- Forum Newbie
- Posts: 15
- Joined: Mon Mar 05, 2012 11:48 am
searching through IPN string to get item_name for each item
hi therer
. iam looking to try and find out how i would go about searching through a string to get back the values posted back to me from paypal to my IPN script. for now i just want to get the item name for each item sold (could be any number) im just not sure how to do it. ive looked at strpos() but im not sure exactly how i should use that. if anyone could point me in the direction of a good tutorial for this type of thing that would be great! 
Re: searching through IPN string to get item_name for each i
PayPal IPNs are sent as a POST request, so you should be able to access $_POST['item_name'] directly. Where, specifically, are you running into problems?
-
eoin.ahern@mycit.ie
- Forum Newbie
- Posts: 15
- Joined: Mon Mar 05, 2012 11:48 am
Re: searching through IPN string to get item_name for each i
em yeah i know i can access them directly. thats fine, its just when i dont know the number of items i want to grab all item names from the string i make from the IPN reply. not sure how to look through the string grab each item_name1 item_name2 ........ etc and put them in an array possibly. im not great with string maniupulation in php as im pretty fresh to the language!
-
eoin.ahern@mycit.ie
- Forum Newbie
- Posts: 15
- Joined: Mon Mar 05, 2012 11:48 am
Re: searching through IPN string to get item_name for each i
can preg_grep() be used to search for a word?
-
eoin.ahern@mycit.ie
- Forum Newbie
- Posts: 15
- Joined: Mon Mar 05, 2012 11:48 am
Re: searching through IPN string to get item_name for each i
cool! ill have a read up on that also! thanks heres what i have so far
$eoinsvars;
foreach ($_POST as $key => $value)
{
urldecode($value);
$eoinsvars.="$value";
}
this gives me back all the values, great! what i want to do now is search string items_name which is a key values get its value and put it in an array!
$eoinsvars;
foreach ($_POST as $key => $value)
{
urldecode($value);
$eoinsvars.="$value";
}
this gives me back all the values, great! what i want to do now is search string items_name which is a key values get its value and put it in an array!
-
eoin.ahern@mycit.ie
- Forum Newbie
- Posts: 15
- Joined: Mon Mar 05, 2012 11:48 am
Re: searching through IPN string to get item_name for each i
so its actually an array in searching not a string this should make things a lot easier
-
eoin.ahern@mycit.ie
- Forum Newbie
- Posts: 15
- Joined: Mon Mar 05, 2012 11:48 am
Re: searching through IPN string to get item_name for each i
here is all i had to do. was pretty easy after all.
$eoinsarray = array();
foreach ($_POST as $key => $value)
{
urldecode($value);
if (strpos($key,'item_name') !== false)
{
$eoinsarray [] = $value;
}
}
$eoinsarray = array();
foreach ($_POST as $key => $value)
{
urldecode($value);
if (strpos($key,'item_name') !== false)
{
$eoinsarray [] = $value;
}
}