Skip to content

Instantly share code, notes, and snippets.

@jeffreycahyono
Created February 24, 2014 17:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jeffreycahyono/9192622 to your computer and use it in GitHub Desktop.
Save jeffreycahyono/9192622 to your computer and use it in GitHub Desktop.
<?php
define('FDATA', sys_get_temp_dir() . '/xsys.txt');
function readXData(){
if(is_readable(FDATA)){
$x = file_get_contents(FDATA);
if($x)
return json_decode($x,TRUE);
}
return array();
}
function getX($key){
$data = readXData();
if(isset($data[$key]))
return $data[$key];
else
return NULL;
}
function isExistsX($key){
return getX($key) !== NULL;
}
function storeX($key, $data){
$x = readXData();
$x[$key] = $data;
file_put_contents(FDATA, json_encode($x));
}
function delX($key){
$x = readXData();
if(isset($x[$key])){
unset($x[$key]);
file_put_contents(FDATA, json_encode($x));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment