public static function write_results_html($fh, $results) { $html = ''; $data = []; // make our own array to avoid modifying the original. foreach ($results as $row) { $myrow = $row; if (isset($myrow['addr'])) { $addr_url = sprintf('http://blockchain.info/address/%s', $myrow['addr']); $myrow['addr'] = sprintf('<a href="%s">%s</a>', $addr_url, $myrow['addr']); } $data[] = $myrow; } if (@$data[0]) { $header = array_keys($data[0]); } else { // bail. return $html; } $table = new html_table(); $table->header_attrs = array(); $table->table_attrs = array('class' => 'walletaddrs bordered'); $html .= $table->table_with_header($data, $header); fwrite($fh, $html); }