LoginSignup
8

More than 5 years have passed since last update.

PHPでオブジェクトを配列に変換

Posted at

PHPのオブジェクトを配列に変換。
stackoverflowで面白い回答を見つけた。

$array = json_decode(json_encode($object), true);

一度jsonにして、decodeするときにtrueをつければ配列になる。

参考

php stdClass to array
http://stackoverflow.com/questions/18576762/php-stdclass-to-array

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
8