如何从php中的数组中提取精确数据

时间:2010-02-02 07:32:39

标签: php arrays

我从数据库中获取了这个数组......如何获得确切的值属性......

Array
(
    [0] => TRowResult Object
        (
            [row] => tests
            [columns] => Array
                (
                    [a21ha:link_0] => TCell Object
                        (
                            [value] =>testsample
                            [timestamp] => 1265010584060
                        )

                    [a21ha:link_1] => TCell Object
                        (
                            [value] => example
                            [timestamp] => 1265092697040
                        )

                )

        )

如何在php中单独获取[value]

2 个答案:

答案 0 :(得分:3)

print $myArray[0]->columns['a21ha:link_0']->value;

这会给你第一个。为了得到所有,你必须遍历内容。

foreach ($myArray[0]->columns as $column) {
  print $column->value;
}

答案 1 :(得分:1)

假设您的数组名为$ array:

foreach($array as $arridx => $rowobj){
    foreach($rowobj->columns as $cellid => $rowcell){
        echo $rowcell->value;
    }
}