I have a $results array produced from a query and I would like to output a table in html. I would like the header to be "id", "length" and "sample_id". Since the header changes every time, so I used
$keys = array_keys($results[0]);
I got "array_keys() expects parameter 1 to be array" error. If the nested part is not an array, how should I get the keys?
array:59 [▼
0 => {#160 ▼
+"id": 204
+"length": 233
+"sample_id": "ad3"
}
1 => {#161 ▼
+"id": 205
+"length": 733.5
+"sample_id": "bt7r"
}
2 => {#162 ▶}
3 => {#163 ▶}
4 => {#164 ▶}
5 => {#165 ▶}
$keys = get_object_vars( $results[0] );