CakePHP Hash::combine() でキーと値の組み合わせがずれる
CakePHP 2.2以降で利用できるHashクラスのcombineメソッドには以下の罠があります。 Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
< ?php $data = [ [ 'id' => 1, 'title' => 'first title', 'body' => 'first content' ], [ 'id' => 3, 'title' => 'second title', 'body' => 'second content', 'more' => 'second more content' ], [ 'id' => 5, 'title' => 'third title', 'body' => 'third content', 'more' => 'third more content' ], ]; $results = Hash::combine($data, '{n}.id', '{n}.more'); |
この場合、$resultsは以下の値にな […]