我希望foreach从数据库获取一行并获取值,但是有错误:
$row->airline
就是:[{"name_airline":"aaaaa"},{"name_airline":"bbbbb"},{"name_airline":"ccccc"}]
foreach ($results->result() as $idx => $row) {
$airline = json_decode($row->airline);
foreach ($airline as $val) {
echo '<td>' . $val . '</td>'; //Line 97
}
}
Eror:
遇到PHP错误
严重程度:4096
消息:类stdClass的对象无法转换为字符串
文件名:core / Loader.php(679):eval()'d code
行号:97
答案 0 :(得分:1)
我想你想要echo '<td>' . $val->name_airline . '</td>'