0.75, 'out' => 297.75, 'device-2' => 198.75, 'device-3' => 397.058, 'device-4' => 595.211 ]; // Calculate joint line segments if ($showJoint) { $activeDevices = array_filter([$showDevice1, $showDevice2, $showDevice3, $showDevice4]); $activeYs = []; foreach ($devicePositions as $device => $y) { if (isset($_GET[$device])) { $activeYs[] = $y; } } // Add top/bottom if first/last device is connected if ($showDevice1) array_unshift($activeYs, 0); if ($showDevice4) $activeYs[] = 596; // Draw segments between consecutive points for ($i = 1; $i < count($activeYs); $i++) { $y1 = $activeYs[$i-1]; $y2 = $activeYs[$i]; echo ""; } } ?>