PHP stores the array into a cache TXT file and retrieves it and restores it to an array. in PHP development, operations on the array are often encountered, sometimes you need to cache the array data to a file to make it easier to directly call the cached array file next time. the reference code is as follows:
// Write an array
$ Array_1 = array (1, '55a', 2, '3d6', 77 );
Var_dump ($ array_1); // outputs the original array structure.
$ Filename = "cache.txt ";
$ File_hwnd = fopen ($ filename, "w ");
Fwrite ($ file_hwnd, serialize ($ array_1); // input serialized data
Fclose ($ file_hwnd );
// Start reading and restoring the array
$ Filename = "cache.txt ";
$ File_hwnd = fopen ($ filename, "r ");
$ Content = fread ($ file_hwnd, filesize ($ filename); // read all contents of the file
Fclose ($ file_hwnd );
$ Array_2 = unserialize ($ content); // converts text data back to an array
Var_dump ($ array_2); // output the current data structure