当前位置:网站首页>学习使用php把stdClass Object转array的方法整理
学习使用php把stdClass Object转array的方法整理
2022-08-04 09:19:00 【徊忆羽菲】
学习使用php把stdClass Object转array的方法整理
对象转数组方法
function object2array_pre(&$object) {
if (is_object($object)) {
$arr = (array)($object);
} else {
$arr = &$object;
}
if (is_array($arr)) {
foreach($arr as $varName => $varValue){
$arr[$varName] = $this->object2array($varValue);
}
}
return $arr;
}
function object2array(&$object) {
$object = json_decode( json_encode( $object),true);
return $object;
}
以上两个方法结合使用
边栏推荐
猜你喜欢
随机推荐
【正点原子STM32连载】第三章 开发环境搭建 摘自【正点原子】MiniPro STM32H750 开发指南_V1.1
ps如何换背景颜色,自学ps软件photoshop2022,3种不同的方式笔记记录
请问下Flink SQL如何写hologres分区表?我想要每天一个分区
Cloud function to achieve automatic website check-in configuration details [Web function/Nodejs/cookie]
ps抠图怎么抠出来,自学ps软件photoshop2022,ps怎么抠出想要的部分-笔记记录
Detailed explanation of NAT/NAPT address translation (internal and external network communication) technology [Huawei eNSP]
Four common methods of network attacks and their protection
MindSpore:【model_zoo】【resnet】尝试用THOR优化器运行时报cannot import name ‘THOR‘
MATLAB绘图总结
速速脱单诀窍
How to restore the Youxuan database with only data files
LeetCode581+621+207
如何快速将Zabbix5.0升级至6.0?
LeetCode中等题之旋转图像
MindSpore:Ascend运行出现问题
Since his 97, I roll but he...
It is found that several WRH tables are locked, what should I do?
tcp连接的细节
外包干了四年,秋招终于上岸了
[Cloud Residency Co-Creation] HCSD Celebrity Live Streaming – Employment Guide