2010-03-11 115 views
1

我有以下阵列AS3例如:如何将AS3中的数组传递给PHP中的数组?

var arrayDefinitionsargsAmfPhp:Array = new Array(); 
arrayDefinitionsargsAmfPhp['tabela'] = "controls"; 
arrayDefinitionsargsAmfPhp['width'] = "100"; 

送他到远程对象的PHP,例如:

async = bridge.getOperation(amfphpFunction).send(arrayDefinitionsargsAmfPhp); 

在PHP中我试图让数组是这样的:

function retornamenu($tableInBd) 
{ 

$arr = array($tableInBd); 

$tableInBdname = $arr['tabela']; 

$widthInBdname = $arr['width']; 

但不幸的是这些变量$ tableInBdname和$ widthInBdname没有来到PHP,有人可以帮我一个例子吗?

感谢已经

回答

0

答案是确定的,解决的办法是:

PHP

function retornamenu($tableInBd) 
{ 

$tableInBdname = $tableInBd['tabela']; 

$mensagem = $tableInBd['mensagem']; 

AS3

var arrayDefinitionsargsAmfPhp:Array = new Array(); 
arrayDefinitionsargsAmfPhp['tabela'] = "controls"; 
    arrayDefinitionsargsAmfPhp['mensagem'] = "este sao dados que vierem via array do as3"; 

async = bridge.getOperation(amfphpFunction).send(arrayDefinitionsargsAmfPhp); 

感谢

0

您可以通过sumbitting值作为发送的URLVariables/..

var variables:URLVariables = new URLVariables(); 
variables.NAME = "Hello"; 
variables.EMAIL = "[email protected]" 

var request:URLRequest = new URLRequest("sentFromFlex.php"); 
request.data = variables; 
request.method = URLRequestMethod.POST; 
sendToURL(urlrequest); 

,并在PHP中,你可以得到$ _POST数组中的这些变量..

echo $_POST['NAME']; 
echo $_POST['EMAIL']; 
+0

这位朋友你好,我使用的远程方法对象RemoteObject()是不同的吨,必须转换成相同的数组为PHP,别人可以帮助我? – luiz 2010-03-11 06:06:11

0
[Bindable] public var rows2:Object = new Object(); 

保留rows2中的所有数据对象并将其分派给PHP。

rows2=Application.application.whateverStuff; 

<mate:eventProperties> 
<mate:EventProperties rows2="{rows2}"/> 
</mate:eventProperties> 

现在在Event属性中,您将获得rows2以及通过Remoting发送给PHP的内容。

public function yourPHP($data) 
    { 
    //return print_r($data,true); 
    if(!$data || !is_array($data)|| !sizeof($data)){throw new Exception("No data sent.".(is_object($data)?"y":"n"));} 
    //throw new Exception(print_r($data,true)); 
    array_shift($data);//get rid of the first row 
    foreach($data as $row) 
    { 
      Now perform your manipulation here. 

     } 
}