当前位置: 首页>>代码示例>>PHP>>正文


PHP array_to_object函数代码示例

本文整理汇总了PHP中array_to_object函数的典型用法代码示例。如果您正苦于以下问题:PHP array_to_object函数的具体用法?PHP array_to_object怎么用?PHP array_to_object使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了array_to_object函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: index

 public function index()
 {
     $this->load->library(['pagination', 'table']);
     $page = !empty($this->uri->segment(4)) ? $this->_perpage * ($this->uri->segment(4) - 1) : 0;
     $config['base_url'] = base_url($this->base . '/index/');
     $config['total_rows'] = $this->{$this->router->fetch_class()}->count_all();
     $this->_set_datagrid_header(isset($this->data['recursive']) ? $this->data['recursive'][1] : NULL);
     $unshift = [$this->primary_key => 'Primary Key'] + $this->data['datagrid_header'] + ['role' => 'Role'];
     $items = $this->_get_items();
     $this->user->order_by($this->primary_key, 'ASC');
     $this->user->limit($this->_perpage, $page);
     foreach ($this->user->with('user_role')->get_all() as $index => $row) {
         $row = object_to_array($row);
         foreach ($row as $k => $v) {
             if (!empty($items) && array_key_exists($k, $items)) {
                 $row[$k] = empty($v) ? $v : $items[$k][$v];
             }
         }
         $row['role'] = '';
         foreach ($row['user_role'] as $key => $value) {
             $role = $this->role->get($value['role_id']);
             $row['role'] .= '<span class="label label-info">' . $role->role_name . '</span> ';
         }
         $row = array_intersect_key($row, $unshift);
         $this->data['datagrid'][$index] = array_to_object($row);
     }
     $this->pagination->initialize($config);
     $this->data['links'] = $this->pagination->create_links();
 }
开发者ID:soniibrol,项目名称:package,代码行数:29,代码来源:User.php

示例2: getAwards

 public static function getAwards()
 {
     $awards = Config::get('awards.types');
     foreach ($awards as &$award) {
         $award = array_to_object($award);
     }
     return $awards;
 }
开发者ID:vanderlin,项目名称:halp,代码行数:8,代码来源:Award.php

示例3: array_to_object

/**
 * Converting an array into object
 *
 * @param   array   $array  Source
 * @return  object
 */
function array_to_object(array $array)
{
    $obj = new stdClass();
    foreach ($array as $key => $val) {
        $obj->{$key} = is_array($val) ? array_to_object($val) : $val;
    }
    return $obj;
}
开发者ID:sanayaCorp,项目名称:e-inventory,代码行数:14,代码来源:biarray_helper.php

示例4: test_array_to_object

 public function test_array_to_object()
 {
     $a = ['key1' => 'val1', 'key2' => 'val2'];
     $o = $this->_get_test_obj();
     $this->assertEquals($o, array_to_object($a));
     $this->assertNotEquals($a, $o);
     $o->key3 = 'val3';
     $this->assertNotEquals($a + ['key3' => 'val3'], array_to_object($o));
 }
开发者ID:yfix,项目名称:yf,代码行数:9,代码来源:function_obj2arr.Test.php

示例5: loadPluginConfi

 protected function loadPluginConfi($object = true)
 {
     $plugin_configuration = array('roles' => get_option('cdm_roles'), 'batch_access' => get_option('cdm_batch_access'), 'client_comment' => get_option('cdm_client_comment'), 'client_upload' => get_option('cdm_client_upload'), 'display_month' => get_option('cdm_display_month'), 'display_year' => get_option('cdm_display_year'), 'display_date' => get_option('cdm_display_date'), 'display_all' => get_option('cdm_display_all'), 'external_css' => get_option('cdm_external_css'), 'secure_files' => get_option('cdm_secure_files'), 'allowed_extension' => get_option('cdm_allowed_extension'), 'update_options' => get_option('cdm_update_options'), 'filesize' => get_option('cdm_allowed_filesize'), 'userrole' => get_option('cdm_userroles'));
     if ($object) {
         return array_to_object($plugin_configuration);
     } else {
         return $plugin_configuration;
     }
 }
开发者ID:josie559,项目名称:client-document-monitoring,代码行数:9,代码来源:init.php

示例6: getByID

 public static function getByID($fsfID)
 {
     $db = Loader::db();
     $r = $db->GetRow('SELECT * FROM FileSetFiles WHERE fsfID = ?', array($fsfID));
     if (is_array($r) && $r['fsfID']) {
         $fsf = new static();
         $fsf = array_to_object($fsf, $r);
         return $fsf;
     }
 }
开发者ID:meixelsberger,项目名称:concrete5-5.7.0,代码行数:10,代码来源:File.php

示例7: testArrayToObject

 public function testArrayToObject()
 {
     $obj1 = new stdClass();
     $obj1->foo = 'bar';
     $obj2 = new stdClass();
     $obj2->foo = $obj1;
     $this->assertEquals(new stdClass(), array_to_object([]));
     $this->assertEquals($obj1, array_to_object(['foo' => 'bar']));
     $this->assertEquals($obj2, array_to_object(['foo' => ['foo' => 'bar']]));
 }
开发者ID:cknow,项目名称:laravel-support,代码行数:10,代码来源:HelpersTest.php

示例8: getByID

 public static function getByID($logID)
 {
     $db = Database::get();
     $r = $db->Execute("select * from Logs where logID = ?", array($logID));
     if ($r) {
         $row = $r->FetchRow();
         $obj = new static();
         $obj = array_to_object($obj, $row);
         return $obj;
     }
 }
开发者ID:digideskio,项目名称:concrete5,代码行数:11,代码来源:LogEntry.php

示例9: get_templates

 private function get_templates()
 {
     $this->load->model('template_model');
     $ids = $this->config->item('index_template_ids');
     $params = buildQueryOperation(array(), $this->common->get_start_row(), $this->common->get_page_size());
     foreach ((array) $ids as $id) {
         $params->QueryOperator->Filter[] = array_to_object(array('Name' => 'ID', 'Value' => $id));
     }
     $result = wrapWcfResult($this->template_model->get_templates_list($params, 'object'), 'Template');
     return empty($result->Data['rows']) ? [] : object_to_array($result->Data['rows']);
 }
开发者ID:ansu2009,项目名称:web,代码行数:11,代码来源:site.php

示例10: array_to_object

 function array_to_object($array)
 {
     $object = new stdClass();
     foreach ($array as $key => $value) {
         if (is_array($value)) {
             $object->{$key} = array_to_object($value);
         } else {
             $object->{$key} = $value;
         }
     }
     return $object;
 }
开发者ID:ArpanTanna,项目名称:seo,代码行数:12,代码来源:array_helper.php

示例11: array_to_object

function array_to_object($array)
{
    $obj = new stdClass();
    foreach ($array as $k => $v) {
        if (is_array($v)) {
            $obj->{$k} = array_to_object($v);
        } else {
            $obj->{$k} = $v;
        }
    }
    return $obj;
}
开发者ID:pbamotra,项目名称:KudosPlease,代码行数:12,代码来源:config_example.php

示例12: Find

 public function Find($where, $args = array())
 {
     $db = Loader::db();
     $return = array();
     $r = $db->GetAll('select * from ' . $this->_table . ' where ' . $where, $args);
     foreach ($r as $row) {
         $o = new $this();
         $o = array_to_object($o, $row);
         $return[] = $o;
     }
     return $return;
 }
开发者ID:meixelsberger,项目名称:concrete5-5.7.0,代码行数:12,代码来源:Model.php

示例13: Find

 public function Find($where)
 {
     $db = Loader::db();
     $r = $db->Execute('select * from UserBannedIPs where ' . $where);
     $ips = array();
     while ($row = $r->FetchRow()) {
         $ip = new self();
         $ip = array_to_object(new self(), $row);
         $ips[] = $ip;
     }
     return $ips;
 }
开发者ID:ppiedaderawnet,项目名称:concrete5,代码行数:12,代码来源:UserBannedIp.php

示例14: get_verify_code_by_code

 /**
  * 根据激活码和应用获取记录
  *
  * @param string $code 激活码
  * @param string $application 应用
  * @return array 返回数组
  */
 public function get_verify_code_by_code($code, $application)
 {
     try {
         $this->load->helper('query_builder');
         $params = buildQueryOperation(array(), 1, 1);
         $params->QueryOperator->Filter = array(array_to_object(array('Name' => 'Code', 'Value' => $code)), array_to_object(array('Name' => 'Application', 'Value' => $application)));
         $result = wrapWcfResult($this->get_verify_codes($params), 'VerifyCode');
         return empty($result->Data['rows'][0]) ? [] : $result->Data['rows'][0];
     } catch (Exception $ex) {
         return [];
     }
 }
开发者ID:ansu2009,项目名称:web,代码行数:19,代码来源:verify_codes_model.php

示例15: get

 private function get($where, $var)
 {
     $q = "select * from Users {$where}";
     $r = $this->connection->query($q, array($var));
     if ($r && $r->numRows() > 0) {
         $row = $r->fetchRow();
         $r->free();
         $ui = $this->application->make('Concrete\\Core\\User\\UserInfo');
         $ui = array_to_object($ui, $row);
         return $ui;
     }
 }
开发者ID:digideskio,项目名称:concrete5,代码行数:12,代码来源:UserInfoFactory.php


注:本文中的array_to_object函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。