how to create array of all members of a class
Posted: Fri Nov 28, 2008 7:22 am
Hello
I need a function that returns a nice path representation of a class. For example
class a
{
var $a1;
var $a2;
function __construct()
{
$this->a1 = new suba();
$this->a2 = new subb();
}
}
class suba
{
var $b1;
var $b2;
}
$arr = magic_function ('a');//pass the name of the class
print_r($a)
/a
/a/a1
/a/a1/b1
/a/a1/b2
/a/a2/b1
/a/a2/b2
So basically create a different kind of print_r. one that returns an array of the path to all members of the class, no matters how many classes down the tree I have.
Thank you
I need a function that returns a nice path representation of a class. For example
class a
{
var $a1;
var $a2;
function __construct()
{
$this->a1 = new suba();
$this->a2 = new subb();
}
}
class suba
{
var $b1;
var $b2;
}
$arr = magic_function ('a');//pass the name of the class
print_r($a)
/a
/a/a1
/a/a1/b1
/a/a1/b2
/a/a2/b1
/a/a2/b2
So basically create a different kind of print_r. one that returns an array of the path to all members of the class, no matters how many classes down the tree I have.
Thank you