The code for writing the following three php arrays into files is to save the array in php format, so that you can run the file in php, and write the cache file, the code for writing the following three php arrays into files is to save the array in php format, so that you can run the file in php, and write the cache file,
Script ec (2); script
The Code is as follows: |
|
$ Str =" "; // Write temp. inc. php $ file = 'temp. inc. php '; $ fo = fopen ($ file, 'w'); fwrite ($ fl, $ str); fclose ($ fo ); |
The Code is as follows: |
|
Function arrayeval ($ array, $ level = 0) {$ space = ""; for ($ I = 0; $ I <= $ level; $ I ++) {$ space. = "" ;}$ evaluate = "array $ space ("; $ comma = "$ space"; if (! Empty ($ array) {foreach ($ array as $ key => $ val) {$ val = empty ($ val )? '': $ Val; $ key = is_string ($ key )? "'". Addcslashes ($ key, ''\')." '": $ key; $ val = is_string ($ val )? "'". Addcslashes ($ val ,''\'). "'": $ val; if (is_array ($ val) {$ evaluate. = "$ comma $ key => ". arrayeval ($ val, $ level + 1);} else {$ evaluate. = "$ comma $ key => $ val" ;}$ comma = ", $ space" ;}}$ evaluate. = "$ space)"; return $ evaluate ;} |
$ File = "./www.111cn.net/file.cache ";
$ Array = array ("count" => "3000", "num" => "300 ");
// Cache
The Code is as follows: |
|
File_put_contents ($ file, serialize ($ array); // write Cache $ Handle = fopen ($ file, "r "); $ Cachearray = unserialize (fread ($ handle, filesize ($ file ))); Print_r ($ cachearray ); |