开发者

Return array from PHP Function

开发者 https://www.devze.com 2023-01-28 09:29 出处:网络
I need a function to return an array as an associate or object, with one input. Here\'s the code. function fetch_article($key) {

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

精彩评论

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