本文整理汇总了PHP中object_to_array函数的典型用法代码示例。如果您正苦于以下问题:PHP object_to_array函数的具体用法?PHP object_to_array怎么用?PHP object_to_array使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了object_to_array函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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";
}
示例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;
}
示例3: json_encode2
function json_encode2($param)
{
if (is_object($param) || is_array($param)) {
$param = object_to_array($param);
}
return json_encode($param);
}
示例4: getMoviesAsArray
function getMoviesAsArray($endpoint)
{
include 'config.php';
$movies = json_decode(file_get_contents($baseUrl . $endpoint));
$movies = object_to_array($movies);
return $movies;
}
示例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();
}
示例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);
}
示例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();
}
}
示例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;
}
示例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();
}
示例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;
}
}
示例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);
}
示例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;
}
示例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("&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();
}
示例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;
}
示例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));
}
}
}
}