4

我想要的只是呼应标题。

以下命令由以下触发器打印:

print_r($results);

Array ( 
   [0] => stdClass Object ( [title] => Title A [catid] => 1 ) 
   [1] => stdClass Object ( [title] => Title B [catid] => 1 ) 
) 

我怎样才能呼应标题 A

亲切的问候!

4

4 回答 4

9

它只是一个对象数组,所以...

$results[0]->title
于 2013-04-22T18:47:27.617 回答
3

要仅打印您可以执行的名称:

foreach($results as $result){
    echo($result->title);
}
于 2013-04-22T18:47:33.960 回答
0
$results = Array ( 
   [0] => stdClass Object ( [title] => Title A [catid] => 1 ) 
   [1] => stdClass Object ( [title] => Title B [catid] => 1 ) 
);

$str = "";

foreach($arr as $item) {
    $result .= $item->title . "\n";
}

print $str;

类似的东西?

于 2013-04-22T18:48:52.980 回答
0
stdClass Object
(
    [0] => Array
        (
            [liquid_id] => 1
            [liquid_name] => lfts
            [amount_per_bottle] => 30
            [qty_used_per_test] => 10
            [location_id] => 1
            [liq_req_per_test] => 3
            [no_of_test_performed] => 0
            [labtest_names] => Absolute Eosinophil count
Bla bla

            [labtest_id] => 1,3,
        )

    [1] => Array
        (
            [liquid_id] => 2
            [liquid_name] => sgpt
            [amount_per_bottle] => 50
            [qty_used_per_test] => 5
            [location_id] => 1
            [liq_req_per_test] => 10
            [no_of_test_performed] => 0
            [labtest_names] => Absolute Eosinophil count
Bla bla

            [labtest_id] => 1,3,
        )

)
于 2014-12-18T08:56:37.260 回答