-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patharray2cache.php
More file actions
50 lines (29 loc) · 766 Bytes
/
array2cache.php
File metadata and controls
50 lines (29 loc) · 766 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
<?php
function arr2_fsave($array, $name, $dir = '') {
$cfile = arr2_fname($name, $dir);
$code = arr2_code($array, $name);
return file_put_contents($cfile, $code);
}
function arr2_fload($name, $dir = ''){
$cfile = arr2_fname($name, $dir);
if (file_exists($cfile)){
include($cfile);
return $$name;
}
return null;
}
function arr2_fname($name, $dir = ''){
if ($dir == '' and defined('CACHEDIR'))
$dir = CACHEDIR.'arrays/';
if (!is_dir($dir)){
if (!mkdir($dir, 0775, True))
return False;
}
return $dir.$name.'.php';
}
function arr2_code($array, $name, $tag = True){
$code = '$'.$name.'='.var_export($array, True);
if ($tag)
$code = '<?php '.$code.'?>';
return $code;
}