Forum Moderators: coopster
<metavalue>a:1:{i:0;a:10:{s:2:"id";s:3:"377";s:12:"variation_id";s:0:"";s:4:"name";s:10:"VPN 7 days";s:3:"qty";i:1;s:9:"item_meta";a:0:{}s:13:"line_subtotal";s:4:"1.99";s:17:"line_subtotal_tax";s:1:"0";s:10:"line_total";s:4:"1.99";s:8:"line_tax";s:1:"0";s:9:"tax_class";s:0:"";}}</metavalue> <?php
$obj = (object)array('a' => 193, 'b' => "hello world", 'id' => 83478, 'c' => array(9, 8, 7));
$s = serialize($obj);
var_dump($s);echo '<br><br>';
$obj2 = unserialize($s);
var_dump($obj2);echo '<br><br>';
echo $obj2->id;
?>
although when I try to unserialize the string you show within <metavalue> it does not work for me
a:1:{
i:0;a:10:{
s:2:"id";s:3:"377";
s:12:"variation_id";s:0:"";
s:4:"name";s:10:"VPN 7 days";
s:3:"qty";i:1;
s:9:"item_meta";a:0:{}
s:13:"line_subtotal";s:4:"1.99";
s:17:"line_subtotal_tax";s:1:"0";
s:10:"line_total";s:4:"1.99";
s:8:"line_tax";s:1:"0";
s:9:"tax_class";s:0:"";
}
}
<?php
//the string which is within your <metavalue> tags:
$s = 'a:1:{i:0;a:10:{s:2:"id";s:3:"377";s:12:"variation_id";s:0:"";s:4:"name";s:10:"VPN 7 days";s:3:"qty";i:1;s:9:"item_meta";a:0:{}s:13:"line_subtotal";s:4:"1.99";s:17:"line_subtotal_tax";s:1:"0";s:10:"line_total";s:4:"1.99";s:8:"line_tax";s:1:"0";s:9:"tax_class";s:0:"";}}';
//will be an array with one indexed item which is another array
$arr = unserialize($s);
//let's give you a visualization of what that array contains
echo '<pre>';print_r($arr);echo '</pre>';
echo $arr[0]['id'];
?>
I think this must be a serialised string of an array?