エンジニア的な技術的なブログ

webエンジニアの開発の知見を書きます。PHP、javascript、postgres、mysql、あと多少のインフラ周りとか。

simplexml_load系の返り値を一気に一発で配列にする方法

 

 $xmlxmlファイルを読み込んだやつね。

 

$sx = simplexml_load_string($xml);

json_decode(json_encode($sx), true);

 

解説はこちら

http://fdays.blogspot.jp/2011/03/php-simplexml.html

 

もし、@attributeとかの属性も細かく取りたいなら

 http://soft.fpso.jp/develop/php/entry_2764.html