phpeveryday.com

The best tutorial of php, php framework, php strategies, object oriented oriented,


PHP WDDX: Using Array Elements

Tag: wddx, distributed data, data type, elements, array   Category: PHP Application
post: 29 Apr 2008 read: 276


Web Distributed Data Exchange Step By Step tutorial - Part 5: It is not like php array. In PHP array, we can have numeric or string indexes. At WDDW, array is only for numeric index. String based indexed array are handled with struct element.

if we want to write:


array(0=>'a', 1=>'b', 2=>'c', 3=>1, 4=>2, 5=>true)

We can use:


<array length='6'>
  <string>a</string>
  <string>b</string>
  <string>c</string>
  <number>1</number>
  <number>2</number>
  <boolean>true</boolean>
</array>

This is example using:


<wddxPacket version='1.0'>
  <header />
  <data>
    <array length='4'>
	  <number>1</number>
	  <string>Wiwit Siswoutomo</string>
	  <string>PHPEveryday.com</string>	  
	  <boolean>1</boolean>	  
    </array>
  </data>
</wddxPacket>

The important note: this is zero based arrays. Creating arrays that are not zero-based, such as array(2=>'c',3=>'d'), would result in a struct with named variables rather than array elements.



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

| Give Your Opinion | Recommend
Share and Bookmark to: These icons link to social bookmarking sites where readers can share and discover new web pages.
digg del.icio.us technorati Ma.gnolia BlinkList

Recommended articles by other readers:
Web Services: How PHP Kiss VB.NET? (Part 1)
Chart: How to Build Cool Animation Real Time Chart
Joomla: Fast Road to Understand Component Programming
Email: Send Attachement Mail
mod_rewrite - Part 1: create your "fantasy" URL

What do You Think?
Your Name *:
Email *:
(Will not be published)
Website/URL:
Your Comment *:
* Required


615
posting