Page 1 of 1
searching through IPN string to get item_name for each item
Posted: Sat Mar 24, 2012 8:34 am
by eoin.ahern@mycit.ie
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
Posted: Sat Mar 24, 2012 8:57 am
by Celauran
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?
Re: searching through IPN string to get item_name for each i
Posted: Sat Mar 24, 2012 9:16 am
by eoin.ahern@mycit.ie
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!
Re: searching through IPN string to get item_name for each i
Posted: Sat Mar 24, 2012 9:35 am
by eoin.ahern@mycit.ie
can preg_grep() be used to search for a word?
Re: searching through IPN string to get item_name for each i
Posted: Sat Mar 24, 2012 9:37 am
by Celauran
I was going to suggest
preg_match_all()
Re: searching through IPN string to get item_name for each i
Posted: Sat Mar 24, 2012 10:08 am
by eoin.ahern@mycit.ie
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!
Re: searching through IPN string to get item_name for each i
Posted: Sat Mar 24, 2012 10:13 am
by eoin.ahern@mycit.ie
so its actually an array in searching not a string this should make things a lot easier
Re: searching through IPN string to get item_name for each i
Posted: Sat Mar 24, 2012 10:30 am
by eoin.ahern@mycit.ie
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;
}
}