在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
Yii2中的对象转数组: $video = Video::find()->asArray()->one(); 把数组转化成任何你想要的对象类型的数组: function array2object($array) { $aboutVideoArr = array(); if (is_array($array)) { foreach ($array as $value) { $video = new Video(); foreach ($value as $key => $val) { $video->$key = $val; } array_push($aboutVideoArr, $video); } } else { $video = $array; } return $aboutVideoArr; } 把对象转化成普通的数组: function object2array($object) { if (is_object($object)) { foreach ($object as $key => $value) { $array[$key] = $value; } } else { $array = $object; } return $array; } |
2022-08-18
2022-08-17
2022-08-15
2022-11-06
2022-08-17
请发表评论