Skip to content

Instantly share code, notes, and snippets.

@erowsika
Last active December 10, 2021 12:41
Show Gist options
  • Select an option

  • Save erowsika/f4495a7377a8de3e675e3e0b73b73615 to your computer and use it in GitHub Desktop.

Select an option

Save erowsika/f4495a7377a8de3e675e3e0b73b73615 to your computer and use it in GitHub Desktop.
<?php
// store result to file
$file_output = [
'unique_jabatan' => 'INSERT_MASTER_JABATAN',
'unique_subbidang' => 'INSERT_MASTER_SUBBIDANG',
'unique_bidang' => 'INSERT_MASTER_BIDANG',
'unique_unitkerja' => 'INSERT_MASTER_UNITKERJA',
];
foreach ($result as $_key => $_item) {
$f = fopen(base_path($file_output[$_key]), 'w');
foreach ($_item as $_value) {
fputs($f, $_value . PHP_EOL);
}
// remove the last eof
$stat = fstat($f);
ftruncate($f, $stat['size'] - 1);
fclose($f);
unset($f, $stat);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment