Itterate arry in php

Dreammonkey
Dreammonkey used Ask the Experts™
on
Hi Experts,

something is driving me mad, I'm using amfphp to send a multidimensional array from flash to php.
I'm able to iterate the structure/objects in the array, but I'm failing at retrieving the values inside of them.

Please have a look at my code, I must be doing something wrong here !
[Flash AS3]
 
var A:String = "this is my A string";
var B:Array = [];
var C:String = "this is my C string";
var D:Array = [];
var E:String = "this is my E string";
 
D.push( { DArray:E } );
B.push( { BString:C, BArray:D });
myArray.push( { myAString:A, myAArray:B });
 
// myArray is the array I'm actually sending from flash to php using amfphp
 
[PHP 5]
 
<?php
 
class MyManager 
{
	public function __construct()
	{
 
	}
 
	function getArray($myArray)
	{
	
		//attempts:
 
		return $myArray[0];
		//returns: myAString : this is my A string ; myAArray : [Object]
 
		return $myArray[0]['myString'];
		//returns Empty String !! (nothing)
 
		return $myArray[0]['myAArray'];
		//returns  0 : [Object]
 
		return $myArray[0]['myAArray'][0];
		//returns  BArray : [Object] ; BString : this is my C string
 
		return $myArray[0]['myAArray'][0]['BString'];
		//returns Empty String !! (nothing)
 
...
	}
}
?>

Open in new window

Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Most Valuable Expert 2011
Top Expert 2016
Commented:
Try using var_dump() to print out the contents of the object.  It is kind of hard to guess without seeing the data!

Author

Commented:
Hi Ray,

I understand your remark is for debugging purposes, is there a way to cast the var_dump method to a string? I really have to do this from flash and i see no easy way for debugging this class in the browser...

Have you got experience with working with amfphp ?

What is striking, almost blowing me away, is that I'm reading out the strings I need only when referring to the object containing it ! When I try to target the string itself it's blank...

That 's why I put up the somewhat crazy code above, it's really exactly the way I'm using it (different values of course but same structure) The return values are hardly believable, are they ?

Regards,

DM

Author

Commented:
here is some real data that got send to amf from flash, recorded by Charles...

thanks for the help...
charles.jpg
Most Valuable Expert 2011
Top Expert 2016
Commented:
I may not be understanding your question.  var_dump() is a function that sends a variable (like an array or object) to the browser output for printing.  It will show empty vars as well as vars that have values.  When you use var_dump() in connection with error_reporting(E_ALL) you can isolate unset variables.  This often indicates an issues of variable scope - like something made private in a class definition.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial