format your code block if you want it reviewed
May 15, 2025
7
Level 1
image
how to show this image to blade php?
static function generateImage($id)
{
$shop= DB::connection('Shop')->table('shoplist')->where('productnum', $id)->first();
if ($shop) {
$binary = bin2hex($shop->ShopImage);
} else {
return false;
}
if ($binary != "00") {
$line = 0;
$table = "<table border='0' style='style:none;' cellpadding='0' cellspacing='0' width='16' height='11'>";
for ($m = 0; $m < 35; $m++) {
$table .= "<tr>";
for ($n = 0; $n < 30; $n++) {
$offset = $line * 8 * 16 + $n * 8;
$color = substr($binary, $offset + 4, 2) . substr($binary, $offset + 2, 2) . substr($binary, $offset, 2);
$table .= "<td style='width:1px;height:1px;background-color:#$color'></td>";
}
$table .= "</tr>";
$line++;
}
$table .= "</table>";
} else {
$table = null;
}
return $table;
}
Please or to participate in this conversation.