2010-03-11 118 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. 

     } 
}