Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/279.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 如何回显stdClass对象标题_Php_Mysql - Fatal编程技术网

Php 如何回显stdClass对象标题

Php 如何回显stdClass对象标题,php,mysql,Php,Mysql,我想要的只是呼应标题 以下命令由以下触发器打印: print_r($results); Array ( [0] => stdClass Object ( [title] => Title A [catid] => 1 ) [1] => stdClass Object ( [title] => Title B [catid] => 1 ) ) 我如何回应标题A 亲切的问候 它只是一个对象数组,所以 $results[0]->titl

我想要的只是呼应标题

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

print_r($results);

Array ( 
   [0] => stdClass Object ( [title] => Title A [catid] => 1 ) 
   [1] => stdClass Object ( [title] => Title B [catid] => 1 ) 
) 
我如何回应标题A


亲切的问候

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

$results[0]->title

要仅打印名称,您可以执行以下操作:

foreach($results as $result){
    echo($result->title);
}

像那样的吗?

好的,谢谢!结果是这样的。但是我怎样才能回显所有的标题呢?使用foreach循环
foreach($res结果){echo$res->title;}
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,
        )

)
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,
        )

)