• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP object_to_array函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: go

 public function go()
 {
     //$feed = file_get_contents($_SERVER['DOCUMENT_ROOT'].'/_add-ons/wordpress/wp_posts.xml');
     //$items = simplexml_load_string($feed);
     $posts_object = simplexml_load_file($_SERVER['DOCUMENT_ROOT'] . '/_add-ons/wordpress/roobottom_old_posts.xml');
     $posts = object_to_array($posts_object);
     $yaml_path = $_SERVER['DOCUMENT_ROOT'] . '/_content/01-blog/';
     foreach ($posts['table'] as $post) {
         if ($post['column'][8] == "publish") {
             $slug = Slug::make($post['column'][5]);
             $slug = preg_replace('/[^a-z\\d]+/i', '-', $slug);
             if (substr($slug, -1) == '-') {
                 $slug = substr($slug, 0, -1);
             }
             $date = date('Y-m-d-Hi', strtotime($post['column'][3]));
             $file = $date . "-" . $slug . ".md";
             if (!File::exists($yaml_path . $file)) {
                 $yaml = [];
                 $yaml['title'] = $post['column'][5];
                 $content = $post['column'][4];
                 $markdown = new HTML_To_Markdown($content, array('header_style' => 'atx'));
                 File::put($yaml_path . $file, YAML::dump($yaml) . '---' . "\n" . $markdown);
             }
             echo $slug . "-" . $date;
             echo "<br/><hr/><br/>";
         }
     }
     return "ok";
 }
开发者ID:roobottom,项目名称:roobottom-statamic,代码行数:29,代码来源:pi.wordpress.php


示例2: saveScore

 public function saveScore()
 {
     try {
         $score = new Score();
         $score->setScore();
         $nCoolType = $score->getType();
         $this->_setScoreDatabase($nCoolType);
         $this->_setScoreCollection($nCoolType);
         $result = $this->connect();
         if (!$result) {
             Log::write('ScoreRecord::saveRecord():connect() failed', 'log');
             return false;
         }
         $this->addIndex(array('insert_time' => -1, 'id' => 1, 'cpid' => 1, 'cyid' => 1, 'cpcy' => array('cpid' => 1, 'cyid' => 1)));
         $result = $this->_mongo->insert($this->_collection, object_to_array($score));
         if ($result === false) {
             Log::write('ScoreRecord::saveRecord():insert() failed', 'log');
             return false;
         }
         return true;
     } catch (Exception $e) {
         Log::write('ScoreRecord::saveRecord() exception, mongErr:' . $this->_mongo->getError() . ' err:' . ' file:' . $e->getFile() . ' line:' . $e->getLine() . ' message:' . $e->getMessage() . ' trace:' . $e->getTraceAsString(), 'log');
     }
     return false;
 }
开发者ID:vvcumt,项目名称:zk,代码行数:25,代码来源:ScoreRecord.class.php


示例3: json_encode2

function json_encode2($param)
{
    if (is_object($param) || is_array($param)) {
        $param = object_to_array($param);
    }
    return json_encode($param);
}
开发者ID:ssolano,项目名称:cafe_sigesp,代码行数:7,代码来源:sigesp_lib_funciones.php


示例4: getMoviesAsArray

function getMoviesAsArray($endpoint)
{
    include 'config.php';
    $movies = json_decode(file_get_contents($baseUrl . $endpoint));
    $movies = object_to_array($movies);
    return $movies;
}
开发者ID:rmlewisuk,项目名称:CouchPotatoTV-Server,代码行数:7,代码来源:shelfGenerator.php


示例5: index

 public function index()
 {
     $p = I('p', 1);
     $sort = I('sort', 'new');
     $cid = I('cid');
     $top = $this->_get_top();
     $req = $top->load_api('FtxiaShuangItemcatsGetRequest');
     $req->setFields('id,name');
     $resp = $top->execute($req);
     $cats = object_to_array($resp->itemcats);
     $this->assign('cats', $cats);
     $top = $this->_get_top();
     $req = $top->load_api('FtxiaShuangItemsGetRequest');
     $req->setFields('num_iid,title,pic_url,price,volume');
     $req->setPageNo($p);
     $req->setCid($cid);
     $req->setSort($sort);
     $req->setTime(date("Y-m-d H"));
     $resp = $top->execute($req);
     $count = $resp->totals;
     $items = object_to_array($resp->items);
     $this->assign('items', $items);
     $pager = $this->_pager($count, '60');
     $this->assign('page', $pager->kshow());
     $this->assign('total', $count);
     $this->assign('cid', $cid);
     $this->assign('sort', $sort);
     $this->assign('nav_curr', 'shuang');
     $this->_config_seo(array('title' => ' 淘宝双十二秒杀专区,1212最值得买的爆款商品	-	' . C('ftx_site_name')));
     $this->display();
 }
开发者ID:leamiko,项目名称:9k9,代码行数:31,代码来源:shuangAction.class.php


示例6: postnwvipbonusadjust2

/**
 * CRM API 加减积分函数封装
 * @param type $vipcode vip卡号
 * @return list
 */
function postnwvipbonusadjust2($vipcode, $vipaccountno, $bonus)
{
    $parm = new StdClass();
    $parm->astr_request = new StdClass();
    $parm->astr_request->header = new StdClass();
    $parm->astr_request->header->username = C('NWVIP_USERNAME');
    $parm->astr_request->header->password = C('NWVIP_PASSWORD');
    $parm->astr_request->header->pagerecords = 20;
    //每页显示多少条信息
    $parm->astr_request->header->pageno = 0;
    //当前第几页
    $parm->astr_request->header->updatecount = 1;
    $parm->astr_request->bonusadjust->vipcode = $vipcode;
    $parm->astr_request->bonusadjust->vipaccountno = $vipaccountno;
    $parm->astr_request->bonusadjust->txdate_yyyymmdd = date('Ymd', time());
    $parm->astr_request->bonusadjust->bonus = $bonus;
    $parm->astr_request->bonusadjust->amount = '0';
    $parm->astr_request->bonusadjust->action = 'A';
    $parm->astr_request->bonusadjust->remark = '';
    $parm->astr_request->bonusadjust->issueby = 'NwVipWeb';
    $parm->astr_request->bonusadjust->reasoncode = '';
    $parm->astr_request->bonusadjust->bonusadjustdocno = '';
    $client = new SoapClient(C('NWVIP_SERVICE_URL'), array('trace' => 1, 'exceptions' => 0));
    $result = $client->postnwvipbonusadjust2($parm);
    return object_to_array($result);
}
开发者ID:NeilFee,项目名称:vipxinbaigo,代码行数:31,代码来源:nwvipfun.php


示例7: getEntitiesArray

function getEntitiesArray($params, $show_password = false)
{
    $return_array = array();
    $entities = getEntities($params);
    if ($entities) {
        foreach ($entities as $entity) {
            $return_array[] = object_to_array($entity);
        }
    }
    return $return_array;
    $return = array();
    $entities = Entity::getEntitiesArray($params, $show_password);
    if (is_array($entities)) {
        foreach ($entities as $entity) {
            $entity['type'] = $params['type'];
            foreach ($entity as $key => $value) {
                if (!is_array($value)) {
                    $value = html_entity_decode($value);
                    $value = strip_tags($value);
                }
                $entity[$key] = $value;
            }
            $return[] = $entity;
        }
        return $return;
    } else {
        return array();
    }
}
开发者ID:socialapparatus,项目名称:socialapparatus,代码行数:29,代码来源:api.php


示例8: LoadModel

 static function LoadModel($model)
 {
     if (isset($this) && $this instanceof OrmManager) {
         $me = $this;
     } else {
         $me = self::singleton();
     }
     if (!$me->outlet) {
         return;
     }
     $models = explode(",", $model);
     //print_pre($models);
     $ret = array();
     foreach ($models as $model) {
         $ormmodel = new OrmModel($model);
         $ormmodel->LoadModel();
         $ret[$model] = $ormmodel;
         if (!empty($ormmodel->classes)) {
             $foo = object_to_array($ormmodel->classes);
             try {
                 $me->outlet->getConfig()->addEntities($foo);
             } catch (Exception $e) {
                 Logger::Error("OrmManager: " . $e->GetMessage());
             }
         }
     }
     $me->outlet->createClasses();
     $me->outlet->createProxies();
     return $ret;
 }
开发者ID:jbaicoianu,项目名称:elation,代码行数:30,代码来源:ormmanager_class.php


示例9: 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


示例10: find_post_type

 /**
  * @param $get_page_arguments
  * @param $new_arr
  *
  * @return false|string
  */
 private function find_post_type($get_page_arguments, $new_arr)
 {
     $post_type = 'page';
     if (array_key_exists('post_type', $get_page_arguments)) {
         $post_type = $get_page_arguments['post_type'];
         return $post_type;
     } else {
         $temp_items = array_values($new_arr);
         $first_item = $temp_items[0];
         if (is_object($first_item)) {
             $first_item = object_to_array($first_item);
         }
         if (is_array($first_item)) {
             if (array_key_exists('post_type', $first_item)) {
                 $post_type = $first_item['post_type'];
                 return $post_type;
             } elseif (array_key_exists('ID', $first_item)) {
                 $post_type = $this->sitepress->get_wp_api()->get_post_type($first_item['ID']);
                 return $post_type;
             }
             return $post_type;
         } elseif (is_numeric($first_item)) {
             $post_type = $this->sitepress->get_wp_api()->get_post_type($first_item);
             return $post_type;
         }
         return $post_type;
     }
 }
开发者ID:SayenkoDesign,项目名称:ividf,代码行数:34,代码来源:class-wpml-remove-pages-not-in-current-language.php


示例11: json_encode_all

/**
 * Convert a value to JSON
 *
 * This function returns a JSON representation of $param. It uses json_encode
 * to accomplish this, but converts objects and arrays containing objects to
 * associative arrays first. This way, objects that do not expose (all) their
 * properties directly but only through an Iterator interface are also encoded
 * correctly.
 */
function json_encode_all(&$param)
{
    if (is_object($param) || is_array($param)) {
        return json_encode(object_to_array($param));
    }
    return json_encode($param);
}
开发者ID:abcarroll,项目名称:DABL,代码行数:16,代码来源:json_encode_all.php


示例12: object_to_array

/**
 * Convert an object into an associative array
 *
 * This function converts an object into an associative array by iterating
 * over its public properties. Because this function uses the foreach
 * construct, Iterators are respected. It also works on arrays of objects.
 *
 * @return array
 */
function object_to_array($var, $loop_exclude = array())
{
    if (is_object($var)) {
        if ($var instanceof JsonSerializable) {
            return $var->jsonSerialize();
        }
        if (in_array($var, $loop_exclude, true)) {
            return '*RECURSION*';
        }
        $loop_exclude[] = $var;
        if ($var instanceof ArrayObject) {
            $var = $var->getArrayCopy();
        } elseif (method_exists($var, 'toArray')) {
            $var = $var->toArray();
        } elseif ($var instanceof Traversable) {
            $var = iterator_to_array($var, true);
        } else {
            $var = get_object_vars($var);
        }
    } elseif (!is_array($var)) {
        throw new InvalidArgumentException('object_to_array can only convert arrays and objects');
    }
    // loop over elements/properties
    foreach ($var as &$value) {
        // recursively convert objects
        if (is_object($value) || is_array($value)) {
            $value = object_to_array($value, $loop_exclude);
        }
    }
    return $var;
}
开发者ID:abcarroll,项目名称:DABL,代码行数:40,代码来源:object_to_array.php


示例13: index

 public function index()
 {
     $p = I('p', 1, 'intval');
     $cid = I('cid', '', 'intval');
     $top = $this->_get_top();
     $req = $top->load_api('FtxiaJuCatsGetRequest');
     $req->setFields('cid,name');
     $resp = $top->execute($req);
     $cats = object_to_array($resp->cats);
     $this->assign('cats', $cats);
     $ltop = $this->_get_top();
     $req = $ltop->load_api('FtxiaJuListsGetRequest');
     $req->setPage($p);
     $req->setCid($cid);
     $req->setTime(date("y-m-d-h", time()));
     $resp = $ltop->execute($req);
     $jus = object_to_array($resp->lists);
     $count = $jus['totalPage'];
     $html = Newiconv("GBK", "UTF-8", urldecode($jus['html']));
     $html = str_replace("data-ks-lazyload", "src", $html);
     $html = str_replace("&amp;id=", "&tm=", $html);
     $html = str_replace("http://detail.ju.taobao.com/home.htm?item_id=", "?m=jump&a=index&iid=", $html);
     $html = str_replace("&tm=", "&from=open.ftxia.com", $html);
     $pager = $this->_pager($count, '1');
     $this->assign('page', $pager->kshow());
     $this->assign('html', $html);
     $this->assign('cid', $cid);
     $this->assign('nav_curr', 'ju');
     $this->_config_seo(array('title' => ' 汇聚最划算的团购商品 - '));
     $this->display();
 }
开发者ID:leamiko,项目名称:9k9,代码行数:31,代码来源:juAction.class.php


示例14: get_format_result

 /** 
  *  转换返回数据
  * 
  *  @access public 
  *  @param  $result 返回结果
  *  @return object 
  */
 function get_format_result($result)
 {
     $r = new OperationResult();
     if (is_object($result)) {
         $result = object_to_array($result);
     }
     if ($result['Status'] == 200) {
         $r->status = 1;
         $r->message = '处理成功';
         $r->data = '';
         if (isset($result['Data']['TotalCount'])) {
             $r->data = new stdClass();
             $r->data->total = $result['Data']['TotalCount'];
             $r->data->rows = isset($result['Data']['List']) ? $result['Data']['List'] : array();
         }
         if (empty($r->data) && !empty($result['Data'])) {
             $r->data = $result['Data'];
         }
     } else {
         $r->status = 0;
         //$r->message = '处理失败';
         $r->message = $result['Message'];
         $r->data = empty($result['Data']) ? '' : $result['Data'];
     }
     return $r;
 }
开发者ID:ansu2009,项目名称:web,代码行数:33,代码来源:WY_Model.php


示例15: icl_register_admin_options

 function icl_register_admin_options($array, $key = "", $option = array())
 {
     if (is_object($option)) {
         $option = object_to_array($option);
     }
     foreach ($array as $k => $v) {
         $option = $key === '' ? array($k => maybe_unserialize($this->get_option_without_filtering($k))) : $option;
         if (is_array($v)) {
             $this->icl_register_admin_options($v, $key . '[' . $k . ']', $option[$k]);
         } else {
             $context = $this->get_context($key, $k);
             if ($v === '') {
                 icl_unregister_string($context, $key . $k);
             } elseif (isset($option[$k]) && ($key === '' || preg_match_all('#\\[([^\\]]+)\\]#', (string) $key, $opt_key_matches) > 0)) {
                 icl_register_string($context, $key . $k, $option[$k]);
                 $vals = array($k => 1);
                 $opt_keys = isset($opt_key_matches) ? array_reverse($opt_key_matches[1]) : array();
                 foreach ($opt_keys as $opt) {
                     $vals = array($opt => $vals);
                 }
                 update_option('_icl_admin_option_names', array_merge_recursive((array) get_option('_icl_admin_option_names'), $vals));
             }
         }
     }
 }
开发者ID:Junaid-Farid,项目名称:gocnex,代码行数:25,代码来源:wpml-admin-texts.class.php


示例16: edit

 public function edit()
 {
     $data['user'] = unserialize($_SESSION['login_user']);
     $bank = $this->db->query("SELECT * FROM bank")->result();
     $data['bank'] = object_to_array($bank, 'nama_bank');
     $this->authlibrary->check_login();
     $this->template->load('template/template_main', 'member/profile/edit', $data);
 }
开发者ID:anggakes,项目名称:permatanetwork,代码行数:8,代码来源:Profile.php


示例17: object_to_array

function object_to_array($obj)
{
    $_arr = is_object($obj) ? get_object_vars($obj) : $obj;
    foreach ($_arr as $key => $val) {
        $val = is_array($val) || is_object($val) ? object_to_array($val) : $val;
        $arr[$key] = $val;
    }
    return $arr;
}
开发者ID:codekissyoung,项目名称:filmfest,代码行数:9,代码来源:functions.php


示例18: konfirmasi

 public function konfirmasi($id_transfer)
 {
     $rule = $this->_rule();
     $this->form_validation->set_rules($rule);
     $transfer = $this->transferreferrallibrary->getData($id_transfer);
     $data['transfer'] = $transfer;
     $data['id_transfer'] = $id_transfer;
     $data['user'] = unserialize($_SESSION['login_user']);
     $data['referral'] = $this->member_model->getData($transfer->data->id_referral, 'id');
     // Form validation
     if ($this->form_validation->run() == FALSE) {
         $bank = $this->db->query("SELECT * FROM bank WHERE country_code = '" . $data['user']->attributes('country_code') . "'")->result();
         $data['bank'] = object_to_array($bank, 'nama_bank');
         $this->template->load('template/template_main', 'member/konfirmasi/konfirmasi_transfer', $data);
     } else {
         $file_name = date('Y-m-j_H-i-s') . "_" . $id_transfer;
         $this->load->library('upload', $this->_upload_conf($file_name));
         if (isset($_FILES['userfile']) && $_FILES['userfile']['size'] > 0) {
             if (!$this->upload->do_upload()) {
                 $this->session->set_flashdata('message', $this->upload->display_errors());
                 $this->session->set_flashdata('sukses', false);
                 redirect(base_url() . "transfer/konfirmasi/" . $id_transfer);
             } else {
                 $data_upload = $this->upload->data();
                 $file = $this->input->post();
                 $file['id_transfer_referral'] = $id_transfer;
                 $file['transfered_at'] = date("Y-m-d");
                 $file['bukti_transfer'] = $file_name . $data_upload['file_ext'];
                 //resize image
                 $this->load->library('image_lib', $this->_resize_conf($file_name . $data_upload['file_ext']));
                 if (!$this->image_lib->resize()) {
                     $this->session->set_flashdata('message', $this->image_lib->display_errors());
                     $this->session->set_flashdata('sukses', false);
                     redirect(base_url() . "transfer/konfirmasi/" . $id_transfer);
                 } else {
                     $this->transferreferrallibrary->transfered($file, $id_transfer);
                     $this->session->set_flashdata('message', "Transfer berhasil harap tunggu verifikasi");
                     $this->session->set_flashdata('sukses', true);
                     redirect(base_url());
                 }
             }
         } else {
             // in here means no file was provided to upload
             // choose to ignore or let them know
             $file = $this->input->post();
             $file['id_transfer_referral'] = $id_transfer;
             $file['transfered_at'] = date("Y-m-d");
             $file['bukti_transfer'] = '';
             $this->transferreferrallibrary->transfered($file, $id_transfer);
             $this->session->set_flashdata('message', "Transfer berhasil harap tunggu verifikasi");
             $this->session->set_flashdata('sukses', true);
             redirect(base_url());
         }
     }
     //end else
 }
开发者ID:anggakes,项目名称:permatanetwork,代码行数:56,代码来源:Transfer.php


示例19: testObjectToArray

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


示例20: setData

 public function setData($data)
 {
     if (!is_array($data)) {
         if (!is_object($data)) {
             throw new \InvalidArgumentException("Write data must be array or object, given: " . gettype($data));
         }
         $data = object_to_array($data);
     }
     $this->data = $data;
 }
开发者ID:wells5609,项目名称:php-util,代码行数:10,代码来源:CsvWriter.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP objectsIntoArray函数代码示例发布时间:2022-05-15
下一篇:
PHP object_textarea_tag函数代码示例发布时间:2022-05-15
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap