0

我有以下数组......从此代码生成。

$aa = new_Arr();

print_r($aa);   //here is the result...


     cl_aa Object
    (
        [data:cl_aa:private] => Array
            (
                [t_a] => Array
                    (
                        [0] => Array
                            (
                                [f_c] => LAL
                                [p_r] => RN
                                [id] => 1214125
                                [gender] => m
                            )
                    )

                [t_b] => Array
                    (
                    )

                [t_l] => Array
                    (
                        [0] => Array
                            (
                                [p_lev] => 2
                                [p_date] => 
                                [p_r] => 
                            )
                    )

                [t_r] => Array
                    (
                        [0] => Array
                            (
                                [I_r] => 19
                            )

                    )

            )

        [db:cl_aa:private] => PDOTester Object
            (
            )
    )

我试着像这样阅读它......

foreach ($aa as $key=>$value) {
     print_r($key);
     echo "<h1>". $value['bb']. "</h1>";
 }

但我看不到结果...

我如何阅读上面的数组?请帮忙?

4

1 回答 1

1

Provide your cl_aa class some getters :

public class cl_aa {

    private $data;
    private $db;

    public function getData() {
        return $this->data;
    }
    public function getDb() {
        return $this->db;
    }
}

And to access your data from outside :

$aa = new_Arr(); // I assume this function returns a cl_aa object.
print_r($aa->getData());
print_r($aa->getDb());

Take a look at this link to learn more about OOP.

于 2013-08-06T14:30:18.323 回答