[英]How to echo stdClass Object Title
What I want is echo the title only. 我要的只是回声标题。
The below command is printed by the following trigger: 以下命令由以下触发器打印:
print_r($results);
Array (
[0] => stdClass Object ( [title] => Title A [catid] => 1 )
[1] => stdClass Object ( [title] => Title B [catid] => 1 )
)
How can I echo just Title A 我该如何回应标题A
Kind regards! 亲切的问候!
它只是一个对象数组,所以...
$results[0]->title
To print just the names you could do: 要仅打印名称,可以执行以下操作:
foreach($results as $result){
echo($result->title);
}
$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;
Something like that? 这样的东西?
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,
)
)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.