Page 1 of 1

Help with accessing array in php

Posted: Fri Apr 25, 2008 7:36 am
by dwain_francis
How can I access the values stored in this array?

array(2) { [0]=> string(795) "a:23:{s:3:"add";s:1:"1";s:3:"cmd";s:5:"_cart";s:8:"business";s:18:"sales@sales.com";s:9:"item_name";s:16:"Where are we now";s:11:"item_number";s:5:"00005";s:6:"amount";s:5:"20.95";s:23:"buyer_credit_promo_code";s:0:"";s:29:"buyer_credit_product_category";s:0:"";s:28:"buyer_credit_shipping_method";s:0:"";s:32:"buyer_credit_user_address_change";s:0:"";s:8:"shipping";s:4:"6.00";s:9:"shipping2";s:4:"2.00";s:12:"shopping_url";s:29:"http://bookstore.astemari.com";s:6:"return";s:36:"http://www.sales.com/thankyou.php";s:13:"cancel_return";s:35:"http://www.sales.com/cancel.html";s:7:"no_note";s:1:"1";s:13:"currency_code";s:3:"USD";s:2:"lc";s:2:"US";s:8:"submit_x";s:2:"50";s:8:"submit_y";s:1:"9";s:8:"quantity";i:9;s:2:"id";i:1209123910;s:2:"ck";s:32:"e4ba5745d8eaf38e7e1184b65b46c501";}" [1]=> string(801) "a:23:{s:3:"add";s:1:"1";s:3:"cmd";s:5:"_cart";s:8:"business";s:18:"sales@sales.com";s:9:"item_name";s:22:"Strangers on the Shore";s:11:"item_number";s:5:"00004";s:6:"amount";s:5:"14.95";s:23:"buyer_credit_promo_code";s:0:"";s:29:"buyer_credit_product_category";s:0:"";s:28:"buyer_credit_shipping_method";s:0:"";s:32:"buyer_credit_user_address_change";s:0:"";s:8:"shipping";s:4:"6.00";s:9:"shipping2";s:4:"2.00";s:12:"shopping_url";s:29:"http://bookstore.astemari.com";s:6:"return";s:36:"http://www.sales.com/thankyou.php";s:13:"cancel_return";s:35:"http://www.sales.com/cancel.html";s:7:"no_note";s:1:"1";s:13:"currency_code";s:3:"USD";s:2:"lc";s:2:"US";s:8:"submit_x";s:2:"41";s:8:"submit_y";s:1:"6";s:8:"quantity";i:3;s:2:"id";i:1209123996;s:2:"ck";s:32:"02cfb3d031063eb8ec0c5f66b237ca2c";}" }

The array is store the the variable $_RETAIL

Re: Help with accessing array in php

Posted: Fri Apr 25, 2008 7:41 am
by aceconcepts
It looks like your array has been serialized - has it?

Re: Help with accessing array in php

Posted: Fri Apr 25, 2008 7:44 am
by dwain_francis
yes it has been serialized.

Re: Help with accessing array in php

Posted: Fri Apr 25, 2008 7:51 am
by aceconcepts
What you'll need to do is unserialize() it.

How do you want to access the array? By key, value etc...

Re: Help with accessing array in php

Posted: Fri Apr 25, 2008 8:04 am
by dwain_francis
Ok, I need to access it by its value.

Re: Help with accessing array in php

Posted: Fri Apr 25, 2008 9:15 am
by aceconcepts
To access the values you would specify the keys associated with the value you want.

Can you post your array - unserialized()