PHP - recursive Array to Object?

前端 未结 14 1291
夕颜
夕颜 2020-12-14 14:10

Is there a way to convert a multidimensional array to a stdClass object in PHP?

Casting as (object) doesn\'t seem to work recu

14条回答
  •  生来不讨喜
    2020-12-14 15:06

    public static function _arrayToObject($array) {
        $json = json_encode($array);
        $object = json_decode($json);
        return $object
    }
    

提交回复
热议问题