PHP stdclass转array的方法

<pre>
<?php
$a = new stdClass();
$a->id = '11 ';
$a->username = 'me';
print_r($a);
$b=object2array($a);
print_r($b);
function object2array($object) {
$object1 = json_decode( json_encode( $object),true);
return $object1;
}
?>
</pre>


输出结果
<pre>

stdClass Object
(
[id] => 11
[username] => me
)
Array
(
[id] => 11
[username] => me
)
</pre>

 

相关文章:

  • 2021-07-13
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-12-12
  • 2022-12-23
  • 2021-09-27
猜你喜欢
  • 2021-12-30
  • 2022-01-04
  • 2022-02-14
  • 2022-02-28
  • 2021-08-11
相关资源
相似解决方案