[英]Return array from PHP Function
I need a function to return an array as an associate or object, with one input. 我需要一个函数以一个输入将数组作为关联或对象返回。 Here's the code.
这是代码。
function fetch_article($key) {
global $sysconfig;
if ($sysconfig['datastore'] == 'wincache') {
$data = wincache_ucache_get($key);
return $data;
}elseif ($sysconfig['datastore'] == 'apc'){
$data = apc_fetch($key);
return $data;
}elseif ($sysconfig['datastore'] == ''){
$data = $db->query("SELECT * FROM pages_content WHERE id = '" . $key . "'");
$data = $data->fetch_assoc();
return $data;
}
}
I don't have that much experience working with functions, so please do bear with me. 我没有太多使用函数的经验,所以请多多包涵。
只需返回包含数组对象的变量是没有问题的。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.