Created
January 5, 2011 08:14
-
-
Save fajran/766050 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<? | |
// baca data dari data.txt (asumsinya udah ada) | |
$f = fopen('data.txt', 'rb'); | |
$data = ''; | |
while (!feof($f)) { | |
$data .= fread($f, 1024); | |
} | |
fclose($f); | |
$d = unserialize($data); // $d adalah php array! | |
// bikin php array $d | |
$d = array(); | |
for ($i=0; $i<10000; $i++) { | |
$d[$i] = 'satu dua tiga empat lima enam tujuh delapan sembilan sepuluh'; | |
} | |
// tulis ke file data.txt | |
$f = fopen('data.txt', 'wb'); | |
fwrite($f, serialize($d)); // di-serialisasi dulu biar si php object jadi string biasa | |
fclose($f); | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<? | |
$f = fopen('data.txt', 'rb'); | |
$data = ''; | |
while (!feof($f)) { | |
$data .= fread($f, 1024); | |
} | |
fclose($f); | |
$d = unserialize($data); | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<? | |
$d = array(); | |
for ($i=0; $i<10000; $i++) { | |
$d[$i] = 'satu dua tiga empat lima enam tujuh delapan sembilan sepuluh'; | |
} | |
$f = fopen('data.txt', 'wb'); | |
fwrite($f, serialize($d)); | |
fclose($f); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment