Created
December 14, 2018 17:41
-
-
Save jerrydeakins/c7f0dd4d657f19a068ce895825b42043 to your computer and use it in GitHub Desktop.
Save/Load array in file
This file contains hidden or 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
$filename = 'array.txt'; | |
// Запись. | |
$data = serialize($bookshelf); // PHP формат сохраняемого значения. | |
//$data = json_encode($bookshelf); // JSON формат сохраняемого значения. | |
file_put_contents($filename, $data); | |
// Чтение. | |
$data = file_get_contents($filename); | |
//$bookshelf = json_decode($data, TRUE); // Если нет TRUE то получает объект, а не массив. | |
$bookshelf = unserialize($data); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment