extend('layouts/main') ?> section('content') ?> $x !== '')); } $s = trim((string) $v); if ($s === '') return []; // JSON 배열 문자열이면 decode if ($s[0] === '[') { $decoded = json_decode($s, true); if (json_last_error() === JSON_ERROR_NONE && is_array($decoded)) { return array_values(array_filter(array_map('trim', $decoded), fn($x) => $x !== '')); } } // 개행 기반 분리 $lines = preg_split("/\r\n|\r|\n/", $s); return array_values(array_filter(array_map('trim', $lines), fn($x) => $x !== '')); } /** * 상세 섹션 렌더 */ function render_detail_section(string $title, $value): string { $lines = normalize_lines($value); if (empty($lines)) return ''; $html = '
'; $html .= '
' . esc($title) . '
'; $html .= '
'; return $html; } /** * 원리금균등상환 * @param float $principal * @param float $annualRate * @param int $years * @return float|int */ function calcEqualPaymentMonthly(float $principal, float $annualRate, int $years): float { $n = $years * 12; $r = ($annualRate / 100.0) / 12.0; if ($n <= 0) return 0.0; if (abs($r) < 1e-12) return $principal / $n; $pow = pow(1.0 + $r, $n); return ($principal * $r * $pow) / ($pow - 1.0); } /** * 원금균등상환 * @param float $principal * @param float $annualRate * @param int $years * @return float|int */ function calcEqualPrincipalAvgMonthly(float $principal, float $annualRate, int $years): float { $n = $years * 12; $r = ($annualRate / 100.0) / 12.0; if ($n <= 0) return 0.0; // 이자합(원금균등): P*r*(n+1)/2 (매달 원금이 선형 감소) $totalInterest = $principal * $r * ($n + 1) / 2.0; $totalPayment = $principal + $totalInterest; return $totalPayment / $n; } function won(float $v): string { return number_format((int) round($v)); } ?>
1 / 1
endSection() ?>