<?php
$file = 'd:\PROJECT\xampp\htdocs\siakad\app\Views\mahasiswa\edit.php';
$content = file_get_contents($file);

// Replace title
$content = str_replace('Tambah Mahasiswa Baru', 'Edit Data Mahasiswa', $content);

// Replace form action
$content = preg_replace('/action="<\?= base_url\(\'mahasiswa\/store\'\) \?>"/i', 'action="<?= base_url(\'mahasiswa/update/\' . $mahasiswa[\'id\']) ?>" method="POST"', $content);

// Replace old('field') with old('field', $mahasiswa['field'] ?? '')
$content = preg_replace('/old\(\'([a-zA-Z0-9_]+)\'\)/', 'old(\'$1\', $mahasiswa[\'$1\'] ?? \'\')', $content);

file_put_contents($file, $content);
echo "Edit.php updated.";
