私は多次元配列を持っている:多次元配列をPHPのオブジェクトに変換する方法は?
$image_path = array('sm'=>$sm,'lg'=>$lg,'secondary'=>$sec_image);
魔女は次のようになります。
[_media_path:protected] => Array
(
[main_thumb] => http://example.com/e4150.jpg
[main_large] => http://example.com/e4150.jpg
[secondary] => Array
(
[0] => http://example.com/e4150.jpg
[1] => http://example.com/e4150.jpg
[2] => http://example.com/e9243.jpg
[3] => http://example.com/e9244.jpg
)
)
と私はオブジェクトに変換し、キーの名前を保持したいと思います。
アイデア?
おかげ
編集:$obj = (object)$image_path;
が動作するようには思えません。私は、オブジェクトを配列をループして作成するためのさまざまな方法が必要です
あなたはオブジェクトをどのように見せたいかの良い例を教えてください。キーをプロパティに変換しますか?どのような目的のためにオブジェクトが必要ですか? – mpen
の代わりに '[]'を使って値を取得する必要があります。 ' - >' – Patrioticcow