PHP - recursive Array to Object?

前端 未结 14 1290
夕颜
夕颜 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 14:53

    The simpliest way to convert an associative array to object is:

    First encode it in json, then decode it.

    like $objectArray = json_decode(json_encode($associtiveArray));

提交回复
热议问题