當前位置: 首頁>>代碼示例>>PHP>>正文


PHP obj_to_array函數代碼示例

本文整理匯總了PHP中obj_to_array函數的典型用法代碼示例。如果您正苦於以下問題:PHP obj_to_array函數的具體用法?PHP obj_to_array怎麽用?PHP obj_to_array使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了obj_to_array函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: handle

 public function handle($data)
 {
     $this->validate_request(["assessment" => ["profile", "questions"]]);
     $assessment = $data->{"assessment"};
     $profileJson = $assessment->{"profile"};
     if (isset($profileJson->{"assessment-id"})) {
         $id = Token::decode($profileJson->{"assessment-id"});
     } else {
         $id = Token::generateNewToken(TOKEN_ASSESSMENT);
     }
     $name = $profileJson->{"assessment-name"};
     $displayname = isset($profileJson->{"display-name"}) ? $profileJson->{"display-name"} : $name;
     $profile = new AssessmentProfile($id, $name, $displayname);
     $questions = [];
     foreach ($assessment->{"questions"} as $questionData) {
         $questionJson = obj_to_array($questionData);
         if (isset($questionData->{"question-id"})) {
             $questionId = Token::decode($questionData->{"question-id"});
         } else {
             $questionId = Token::generateNewToken(TOKEN_QUESTION);
         }
         $question = [];
         $question["id"] = $questionId->toString();
         $question["data"] = $questionJson;
         $questions[] = $question;
     }
     return ["assessment" => AssessmentBackend::create_assessment($profile, $questions)->toExternalForm()];
 }
開發者ID:JamesFitzpatrick-Coursework,項目名稱:Web-API,代碼行數:28,代碼來源:AssessmentCreateEndpoint.php

示例2: getAllForSchemaOption

 /**
  * 獲得全部文章分類--無限極分類(編輯菜單時選項)
  *
  * @descript  遞歸組合無限極分類,為了編輯頁麵和增加頁麵select 展示
  * @param $name 表單name名稱
  * @param $id 當前id
  * @return array
  * @author yangyifan <yangyifanphp@gmail.com>
  */
 public static function getAllForSchemaOption($name, $id = 0, $first = true)
 {
     //加載函數庫
     load_func('common');
     $data = $id > 0 ? merge_tree_node(obj_to_array(self::where('id', '<>', $id)->where('user_info_id', '=', is_user_login())->where('deleted_at', '=', '0000-00-00 00:00:00')->get())) : merge_tree_node(obj_to_array(self::where('user_info_id', '=', is_user_login())->get()));
     $first == true && array_unshift($data, ['id' => '0', $name => '頂級分類']);
     return $data;
 }
開發者ID:iwillhappy1314,項目名稱:laravel-admin,代碼行數:17,代碼來源:SiteCatModel.php

示例3: getAllCategory

 /**
  * 獲得全部分類
  *
  * @return \Illuminate\Database\Eloquent\Collection|static[]
  */
 public static function getAllCategory()
 {
     //加載函數庫
     load_func('common');
     $data = obj_to_array(self::all());
     $data = array_to_obj(merge_tree_child_node($data));
     return $data;
 }
開發者ID:iwillhappy1314,項目名稱:laravel-admin,代碼行數:13,代碼來源:BaseModel.php

示例4: getUserForumCat

 /**
  * 獲得當前欄目全部角色權限
  *
  * @param null $role_id
  * @return mixed
  * @author yangyifan <yangyifanphp@gmail.com>
  */
 public static function getUserForumCat($forum_cat_id)
 {
     if (!empty($forum_cat_id)) {
         //加載函數庫
         load_func('common');
         return obj_to_array(DB::table('forum_access AS fa')->select('r.id', 'r.role_name')->join('role AS r', 'fa.role_id', '=', 'r.id')->where('fa.forum_cat_id', '=', $forum_cat_id)->get());
     }
     return false;
 }
開發者ID:iwillhappy1314,項目名稱:laravel-admin,代碼行數:16,代碼來源:ForumCatModel.php

示例5: obj_to_array

function obj_to_array($obj)
{
    $array = is_object ? (array) $obj : $obj;
    foreach ($array as $k => $v) {
        if (is_object($v) or is_array($v)) {
            $array[$k] = obj_to_array($v);
        }
    }
    return $array;
}
開發者ID:rafaeletc,項目名稱:master_tape,代碼行數:10,代碼來源:icecast.php

示例6: saveUserSession

 /**
  * 寫入用戶信息到SESSION
  *
  * @param $user_info
  * @author yangyifan <yangyifanphp@gmail.com>
  */
 private static function saveUserSession($user_info)
 {
     //引入函數庫
     load_func('common');
     $user_info = obj_to_array($user_info);
     $user_info['user_user_data'] = ['id' => $user_info['id'], 'email' => $user_info['email'], 'updated_at' => $user_info['updated_at']];
     $user_info['sign'] = hash_user_sign($user_info['user_user_data']);
     Session::put('user_info', $user_info);
     Session::save();
 }
開發者ID:iwillhappy1314,項目名稱:laravel-admin,代碼行數:16,代碼來源:UserModel.php

示例7: handlePost

 private function handlePost($data)
 {
     $this->validate_request(["question"]);
     $profile = AssessmentBackend::fetch_assessment_profile(Token::decode($this->params['id']));
     $questionId = Token::decode($this->params['question']);
     $question = [];
     $question["id"] = $questionId->toString();
     $question["data"] = obj_to_array($data->{"question"});
     AssessmentBackend::update_question($profile, $questionId, $question);
     return $this->handleGet($data);
 }
開發者ID:JamesFitzpatrick-Coursework,項目名稱:Web-API,代碼行數:11,代碼來源:AssessmentLookupQuestionEndpoint.php

示例8: getUserChoseCagetory

 /**
  * 獲得全部分類
  *
  * @return mixed
  * @author yangyifan <yangyifanphp@gmail.com>
  */
 public static function getUserChoseCagetory()
 {
     //加載函數庫
     load_func('common');
     //獲得當前用戶全部新聞分類
     $user_new_category_id = self::getUserCagetory();
     $all_category = self::all();
     if (!empty($all_category)) {
         foreach ($all_category as &$category) {
             $category->checked = in_array($category->id, $user_new_category_id) ? true : false;
         }
     }
     $all_category = obj_to_array($all_category);
     return array_to_obj(merge_tree_child_node($all_category));
 }
開發者ID:iwillhappy1314,項目名稱:laravel-admin,代碼行數:21,代碼來源:NewsModel.php

示例9: get_slider

/**
 * 顯示滑動圖.
 */
function get_slider()
{
    //滑動頁數量
    $_int_count_slider = 5;
    //取得文章資料
    $_obj_posts = get_posts(array('numberposts' => $_int_count_slider, 'meta_key' => '_thumbnail_id'));
    //將物件轉陣列
    $_arr_posts = obj_to_array($_obj_posts);
    //取得特色圖網址
    foreach ($_arr_posts as $val) {
        $val['url_thumb_img'] = wp_get_attachment_url(get_post_thumbnail_id($val['ID']));
        $_arr_slider_posts[] = $val;
    }
    include_once 'slider.php';
}
開發者ID:allenplay1124,項目名稱:allenplay2016,代碼行數:18,代碼來源:functions.php

示例10: getFullUserMenu

 /**
  * 獲得組合用戶全部分類[組合好]
  *
  * @param null $role_id
  * @return array
  * @author yangyifan <yangyifanphp@gmail.com>
  */
 public static function getFullUserMenu($role_id = null)
 {
     //加載函數庫
     load_func('common');
     $role_id = self::getRoleId($role_id);
     $all_menu = self::where('deleted_at', '=', '0000-00-00 00:00:00')->get();
     $all_user_menu = self::getUserRelationMenu($role_id);
     if (!empty($all_menu)) {
         foreach ($all_menu as &$menu) {
             $menu->checked = in_array($menu->id, $all_user_menu) ? true : false;
         }
     }
     //組合數據
     $all_menu = merge_tree_child_node(obj_to_array($all_menu));
     return array_to_obj($all_menu);
 }
開發者ID:iwillhappy1314,項目名稱:laravel-admin,代碼行數:23,代碼來源:AccessModel.php

示例11: handle

 public function handle($data)
 {
     $this->validate_request(["question"]);
     $assessment = AssessmentBackend::fetch_assessment_profile(Token::decode($this->params['id']));
     $questionJson = obj_to_array($data->{"question"});
     if (isset($data->{"question"}->{"question-id"})) {
         $questionId = Token::decode($data->{"question"}->{"question-id"});
     } else {
         $questionId = Token::generateNewToken(TOKEN_QUESTION);
     }
     $question = [];
     $question["id"] = $questionId->toString();
     $question["data"] = $questionJson;
     AssessmentBackend::add_question($assessment, $question);
     return [];
 }
開發者ID:JamesFitzpatrick-Coursework,項目名稱:Web-API,代碼行數:16,代碼來源:AssessmentAddQuestionEndpoint.php

示例12: is_express

/**
 * 快遞模塊
 * 
 * @access public
 * @param string $str
 * @return string
 */
function is_express($str)
{
    if (is_numeric($str)) {
        $postid = strlen($str);
        switch ($postid) {
            case 10:
                $type = "yuantong";
                break;
            case 12:
                $type = "shunfeng";
                break;
            case 13:
                $type = "yunda";
                break;
        }
        if (isset($type)) {
            $data = obj_to_array(json_decode(express($type, $str)));
            return get_express_data($data);
        }
    }
}
開發者ID:lapuda,項目名稱:webqq-robot,代碼行數:28,代碼來源:app.php

示例13: getCategories

 /**
  * @return array
  */
 public function getCategories()
 {
     return ["select"] + obj_to_array(get_terms('category', array('hide_empty' => 0)), 'term_id', 'name');
 }
開發者ID:elolli,項目名稱:DreamItReelProductions-Website,代碼行數:7,代碼來源:Content.php

示例14: getForumLocation

 /**
  * 獲得全部論壇分類
  *
  * @param $data
  * @author yangyifan <yangyifanphp@gmail.com>
  */
 public static function getForumLocation($data)
 {
     //加載函數庫
     load_func('common');
     $all_category = obj_to_array(self::select('cat_name', 'id', 'pid')->get());
     $data = get_location($all_category, $data->forum_cat_id);
     //翻轉函數
     $data = array_reverse($data);
     return $data;
 }
開發者ID:91xcode,項目名稱:laravel-admin,代碼行數:16,代碼來源:ForumModel.php

示例15: obj_to_array

/**
 * 對象轉數組
 * 
 * @access public
 * @param object $obj
 * @return array
 */
function obj_to_array($obj)
{
    $ret = array();
    foreach ($obj as $key => $value) {
        if (gettype($value) == 'array' || gettype($value) == 'object') {
            $ret[$key] = obj_to_array($value);
        } else {
            $ret[$key] = $value;
        }
    }
    return $ret;
}
開發者ID:lapuda,項目名稱:webqq-robot,代碼行數:19,代碼來源:commons.php


注:本文中的obj_to_array函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。