Ultimi Tweet:
<?php
/**
* Encode raw data to url token
*
* @return string
* @author Caffeina
**/
protected function encode_data($data){
return urlencode(base64_encode(gzcompress(json_encode($data))));
}
<?php
/**
* Decode token to object
*
* @return mixed
* @author Caffeina
**/
protected function decode_data($packet){
return json_decode(gzuncompress(base64_decode(urldecode($packet))),true);
}
<?php
function memoize(&$callback){
return $callback = function() use ($callback,$cache){
static $cache = array();
$args = func_get_args();
$hash_key = implode(',',$args);
return isset($cache[$hash_key])?$cache[$hash_key]:$cache[$hash_key]=call_user_func_array($callback, $args);
};
}