PHPEveryday.com PHP and Web Development Tutorial
What are you looking for?


PHP WDDX: Unserializing Data


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 ) 
)


Series this article:
PHP WDDX: Introduction
PHP WDDX: Understanding Anatomy of WDDX
PHP WDDX: Understanding Data Elements
PHP WDDX: Understanding Simple Data Type
PHP WDDX: Using Array Elements
PHP WDDX: Struct Element
PHP WDDX: Recordset Element
PHP WDDX: Simple Serialization Using PHP function
PHP WDDX: Complex Serialization
PHP WDDX: Unserializing Data
PHP WDDX: Creating Web Service Server
PHP WDDX: Creating Web Service Client


Tag: wddx. distributed data, unserialization Category: PHP Application Post : April 30th 2008 Read: 2,856 Bookmark and Share

blog comments powered by Disqus


Database Tutorial
  • Learn PHP MySQL
  • Learn PHP ADOdb
  • Learn PHP Data Object/PDO
  • Learn PHP XML
  • Learn PHP SimpleXML
Security Tutorial
  • Learn PHP Security
  • Learn HTTP Authentication
  • Learn PHPSecureSite
Framework Tutorial
  • Learn CodeIgniter
  • Learn Joomla
  • Learn Smarty
  • Learn Zend Framework
Template Tutorial
  • Learn Joomla Template
  • Learn WordPress Template
API Tutorial
  • Learn Facebook
JS Framework Tutorial
  • Learn MooTools
  • Learn JQuery
AJAX Tutorial
  • Learn AJAX in 10 Minutes
  • Learn AJAX Client Side
  • Learn AJAX PHP
  • Learn AJAX Remote Server
  • Learn AJAX Repetitive
  • Learn AJAX MySQL
  • Learn AJAX Grid
Web Services Tutorial
  • Learn Web Services NuSOAP
  • Learn Web Services WSDL
  • Learn Web Services WSDL Array
  • Learn Web Services .NET Grid
  • Learn Web Services WDDX
Package Post
  • Joomla Intro
  • Joomla Component
  • Joomla Module
  • Joomla MVC
  • Joomla MVC Backend
  • PostNuke Intro
  • Zend Framework Intro
  • Zend Framework Action
  • Zend Framework Database
  • Zend Framework Registry
  • Zend Framework Config
  • Zend Framework Login
  • Zend Framework Session
  • PHP Array Tips
  • PHP File Tips
  • PHP Email
  • PHP Ms Excel
  • PHP Pattern
  • PHP SMS
  • Flash Database
  • PHP Multitier
  • jQuery Introduction
  • jQuery Selectors
  • Portable Web Server
  • Web Mobile Intro
  • Drupal Installation
  • Drupal Configuration