Skip to content

Commit e90bd01

Browse files
author
AK
committed
create file array2cache.php
0 parents  commit e90bd01

File tree

2 files changed

+39
-0
lines changed

2 files changed

+39
-0
lines changed

array2cache.php

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<?php
2+
3+
function arr2_save($array, $name, $dir = '') {
4+
5+
$cfile = ar2c_fname($name, $dir);
6+
$code = '<?php $array='.var_export($array, True).'?>';
7+
8+
return file_put_contents($cfile, $code);
9+
10+
}
11+
12+
function arr2_array($name, $dir) {
13+
14+
$cfile = arr2_fname($name, $dir = '');
15+
16+
if (file_exists($cfile)){
17+
include($cfile);
18+
return $array;
19+
}
20+
21+
return null;
22+
}
23+
24+
25+
function arr2_fname($name, $dir = ''){
26+
27+
if ($dir == '' and defined('CACHE_DIR'))
28+
$dir = CACHE_DIR;
29+
30+
return $dir.'arrays/'.sha1($name).'.php';
31+
}
32+

composer.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"name":"array2cache",
3+
"version":"1.0.0",
4+
"require":{
5+
"php":">=5.3.0"
6+
}
7+
}

0 commit comments

Comments
 (0)