Jennifer Anthony
Jennifer Anthony

Reputation: 2277

Decode for json value?

I want foreach a row from database and get value it, but have error:

$row->airline is this: [{"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:

A PHP Error was encountered

Severity: 4096

Message: Object of class stdClass could not be converted to string

Filename: core/Loader.php(679) : eval()'d code

Line Number: 97

Upvotes: 0

Views: 141

Answers (1)

Clive
Clive

Reputation: 36965

I think you want echo '<td>' . $val->name_airline . '</td>'

Upvotes: 1

Related Questions