本文整理汇总了PHP中obj_to_array函数的典型用法代码示例。如果您正苦于以下问题:PHP obj_to_array函数的具体用法?PHP obj_to_array怎么用?PHP obj_to_array使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了obj_to_array函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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 <[email protected]>
*/
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 <[email protected]>
*/
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 <[email protected]>
*/
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 <[email protected]>
*/
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 <[email protected]>
*/
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 <[email protected]>
*/
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
示例16: getUserMenuSide
/**
* 获得当前用户全部菜单--递归(左侧菜单显示)
*
* @return array
* @author yangyifan <[email protected]>
*/
public static function getUserMenuSide()
{
//加载函数库
return merge_tree_child_node(obj_to_array(DB::table('role_relation_menu AS rrm')->select('m.*')->join('menu AS m', 'rrm.menu_id', '=', 'm.id')->where('role_id', '=', self::getRoleId())->get()));
}
开发者ID:iwillhappy1314,项目名称:laravel-admin,代码行数:11,代码来源:MenuModel.php
示例17: getAllForMenuSide
/**
* 获得全部菜单--递归(左侧菜单显示)
*
* @return array
* @auther yangyifan <[email protected]>
*/
public static function getAllForMenuSide()
{
//加载函数库
load_func('common');
return merge_tree_child_node(obj_to_array(self::all()));
}
开发者ID:jiangtong1125,项目名称:laravel-admin,代码行数:12,代码来源:MenuModel.php
示例18: getRoleList
/**
* 获得角色列表
*
* @return mixed
* @author yangyifan <[email protected]>
*/
public static function getRoleList()
{
//加载函数库
load_func('common');
return obj_to_array(DB::table('role')->where('status', '=', 1)->get());
}
开发者ID:iwillhappy1314,项目名称:laravel-admin,代码行数:12,代码来源:RoleModel.php
示例19: getLyric
function getLyric($artist, $song)
{
$url = str_replace('\'', '', 'http://api.chartlyrics.com/apiv1.asmx/SearchLyricDirect?artist=' . urlencode($artist) . '&song=' . urlencode($song));
$xml = simplexml_load_file($url, 'SimpleXMLElement', LIBXML_NOCDATA);
$xml = obj_to_array($xml);
// print_r($xml);
if ($xml['LyricId'] && $xml['Lyric'] != array()) {
return $xml['Lyric'];
} else {
return 'Sorry, there\'s no lyric found for this song';
}
}
开发者ID:sinas06,项目名称:icecast-now-playing-script,代码行数:12,代码来源:icecast.php
示例20: getAll
/**
* 获得全部文章分类
*
* @return array
* @auther yangyifan <[email protected]>
*/
public static function getAll()
{
//加载函数库
load_func('common');
return merge_tree_node(obj_to_array(self::mergeData(self::all())));
}
开发者ID:hushulin,项目名称:laravel-admin,代码行数:12,代码来源:ArticleCatModel.php
注:本文中的obj_to_array函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论