
PHP里如何解析flex中的arraycollection数据类型 20
这种数据类型我在PHP里接收后自动判断为string,如何让它变成xml或者数组一类方便编辑的数据啊?能给我个实例么?或者给我下你的QQ教教我...
这种数据类型我在PHP里接收后自动判断为string,如何让它变成xml或者数组一类方便编辑的数据啊?
能给我个实例么?或者给我下你的QQ教教我 展开
能给我个实例么?或者给我下你的QQ教教我 展开
展开全部
Actually, you can create an ArrayCollection type on the PHP side and send native ArrayCollection objects directly over AMF.
Here is some php code I have that works. Save this in a file called
ArrayCollection.php
<?php
class ArrayCollection {
public function getASClassName()
{
return 'flex.messaging.io.ArrayCollection';
}
var $source = array();
function ArrayCollection()
{
$this->source = array();
}
}
To use this on the php side include the ArrayCollection.php in your php project and the syntax to call it looks something like this:
$myArrayCollection = new ArrayCollection();
and if you want to access the array that composes the ArrayCollection you can do this
$someArray = $myArrayCollection->source;
On the Flex side you can pass Array Collections directly to the server over Zend AMF. In one of my projects I have many value objects that have ArrayCollections in them and they work just fine on the PHP side. So it can be done.
If you absolutely can't get the ArrayCollection working in PHP you can just access the array as the "source" property of the ArrayCollection in Actionscript. The code looks something like this in actionscript:
import mx.collections.ArrayCollection;
public var myAC:ArrayCollection = new ArrayCollection();
public var myArray:Array = new Array();
// populate your ArrayCollection with data...
myArray = myAC.source;
myArray will now be an Array of the objects in the ArrayCollection myAC.
Hope this helps. If you have further questions and/or have a code sample let me know.
It took me a bit to figure this one out too.
Here is some php code I have that works. Save this in a file called
ArrayCollection.php
<?php
class ArrayCollection {
public function getASClassName()
{
return 'flex.messaging.io.ArrayCollection';
}
var $source = array();
function ArrayCollection()
{
$this->source = array();
}
}
To use this on the php side include the ArrayCollection.php in your php project and the syntax to call it looks something like this:
$myArrayCollection = new ArrayCollection();
and if you want to access the array that composes the ArrayCollection you can do this
$someArray = $myArrayCollection->source;
On the Flex side you can pass Array Collections directly to the server over Zend AMF. In one of my projects I have many value objects that have ArrayCollections in them and they work just fine on the PHP side. So it can be done.
If you absolutely can't get the ArrayCollection working in PHP you can just access the array as the "source" property of the ArrayCollection in Actionscript. The code looks something like this in actionscript:
import mx.collections.ArrayCollection;
public var myAC:ArrayCollection = new ArrayCollection();
public var myArray:Array = new Array();
// populate your ArrayCollection with data...
myArray = myAC.source;
myArray will now be an Array of the objects in the ArrayCollection myAC.
Hope this helps. If you have further questions and/or have a code sample let me know.
It took me a bit to figure this one out too.
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询