unserialize and arrays

need to get access to the arrays within a serialized table entry

Page 1 of 1

2 Replies - 2130 Views - Last Post: 26 October 2006 - 06:21 AM Rate Topic: -----

#1 onlineweb  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 25-October 06

unserialize and arrays

Posted 25 October 2006 - 02:34 PM

hi there

i have a database which is a database to store seesions data - the resulting field is serialized but it holds arrays witin arrays (i think)

i created the code below

print $carttotal->Fields('data')";
// Unserialize the data
$var = unserialize ($carttotal->Fields('data'));
print "<br><br>vardump<br><BR>";
// Show what the unserialized data looks like.
var_dump ($var);



to give this result

a:24:{s:11:"editor_mode";s:0:"";s:8:"is_robot";s:1:"N";s:5:"robot";s:0:"";s:11:"is_location";s:0:"";s:9:"adaptives";a:1:{s:14:"is_first_start";s:0:"";}s:11:"logout_user";s:0:"";s:26:"session_failed_transaction";s:0:"";s:16:"add_to_cart_time";s:0:"";s:17:"always_allow_shop";s:0:"";s:16:"current_url_page";s:40:"http://www.nvfwroughtiron.co.uk/test.php";s:12:"current_date";i:1161810170;s:19:"session_create_date";i:1161808836;s:4:"wlid";s:0:"";s:10:"js_enabled";s:1:"Y";s:11:"top_message";s:0:"";s:15:"referer_session";s:48:"http://www.nvfwroughtiron.co.uk/cart/install.php";s:5:"login";s:0:"";s:10:"login_type";s:0:"";s:11:"identifiers";a:0:{}s:6:"logged";s:0:"";s:14:"remember_login";b:0;s:13:"remember_data";s:0:"";s:7:"old_lng";s:0:"";s:4:"cart";s:0:"";}above serialised

now unserialized

vardump

array(24) { ["editor_mode"]=> string(0) "" ["is_robot"]=> string(1) "N" ["robot"]=> string(0) "" ["is_location"]=> string(0) "" ["adaptives"]=> array(1) { ["is_first_start"]=> string(0) "" } ["logout_user"]=> string(0) "" ["session_failed_transaction"]=> string(0) "" ["add_to_cart_time"]=> string(0) "" ["always_allow_shop"]=> string(0) "" ["current_url_page"]=> string(40) "http://www.nvfwroughtiron.co.uk/test.php" ["current_date"]=> int(1161810170) ["session_create_date"]=> int(1161808836) ["wlid"]=> string(0) "" ["js_enabled"]=> string(1) "Y" ["top_message"]=> string(0) "" ["referer_session"]=> string(48) "http://www.nvfwroughtiron.co.uk/cart/install.php" ["login"]=> string(0) "" ["login_type"]=> string(0) "" ["identifiers"]=> array(0) { } ["logged"]=> string(0) "" ["remember_login"]=> bool(false) ["remember_data"]=> string(0) "" ["old_lng"]=> string(0) "" ["cart"]=> string(0) "" } 


my question is how do i get access to the arrays or one single result ie ["current_date"] to get the result 1161810170

hope this makes sense

Is This A Good Question/Topic? 0
  • +

Replies To: unserialize and arrays

#2 snoj  Icon User is offline

  • Married Life
  • member icon

Reputation: 93
  • View blog
  • Posts: 3,583
  • Joined: 31-March 03

Re: unserialize and arrays

Posted 25 October 2006 - 03:49 PM

$variable['array_key'] would do the trick.
Was This Post Helpful? 0
  • +
  • -

#3 onlineweb  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 25-October 06

Re: unserialize and arrays

Posted 26 October 2006 - 06:21 AM

View Posthotsnoj, on 25 Oct, 2006 - 03:49 PM, said:

$variable['array_key'] would do the trick.



hi thanks for the reply

ok yes the above works

echo $data['current_date'];

gives the result correctly - but some of the results have arrays within it eg
echo $data['cart']; gives the result ARRAY

basically i the detail i want to get access to is an entry called 'subtotal' which is held within an array for the holding variable 'cart'
any ideas?

cheers
mike
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1