Web Distributed Data Exchange Step By Step tutorial - Part 10: You can unserialize data by PHP's function, wddx_deserialize(). This function will unserialize WDDX packet and returns the corresponding native PHP data type. It is simple, look this sample:
<?php
// example data
$arrBooks = array(array('id'=>1,'title'=>'PHP Undercover'),
array('id'=>2,'title'=>'PHP Webservices'),
array('id'=>3,'title'=>'Zend Framework')
);
// add header
$wddxst = wddx_packet_start('We build a start');
// add some variables
$rowCount = count($arrBooks);
$fieldCount = 2;
wddx_add_vars($wddxst,'rowCount','fieldCount');
// add complex variable
$i = 0;
for($i=0;$i<$rowCount;$i++){
$varname = 'book'.$i;
$$varname = $arrBooks[$i];
wddx_add_vars($wddxst, $varname);
}
$packet = wddx_packet_end($wddxst);
// unserialize
$data = wddx_deserialize($packet);
// test
print_r($data);
?>
The result:
Array (
[rowCount] => 3
[fieldCount] => 2
[book0] => Array ( [id] => 1 [title] => PHP Undercover )
[book1] => Array ( [id] => 2 [title] => PHP Webservices )
[book2] => Array ( [id] => 3 [title] => Zend Framework )
)