+ add the function of zset().

This commit is contained in:
wangchunsheng
2013-01-10 15:16:34 +00:00
parent d902ffe641
commit fc83f4c963

View File

@@ -499,6 +499,27 @@ function a($var)
echo "</xmp>";
}
/**
* When the $var has the $key, return it, esle result one default value.
*
* @param array|object $var
* @param string|int $key
* @param mixed $valueWhenNone value when the key not exits.
* @param mixed $valueWhenExists value when the key exits.
* @access public
* @return void
*/
function zset($var, $key, $valueWhenNone = '', $valueWhenExists = '')
{
$var = (array)$var;
if(isset($var[$key]))
{
if($valueWhenExists) return $valueWhenExists;
return $var[$key];
}
return $valueWhenNone;
}
/**
* Judge the server ip is local or not.
*