开发者

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 do开发者_开发知识库n't have that much experience working with functions, so please do bear with me.


It's no problem to just return the variable holding the array object.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜