<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/">
  <channel>
    <title>Array on php-tips.com</title>
    <link>https://php-tips.com/tags/array/</link>
    <description>Recent content in Array on php-tips.com</description>
    <generator>Hugo</generator>
    <language>ja</language>
    <lastBuildDate>Wed, 18 Dec 2013 10:13:13 +0900</lastBuildDate>
    <atom:link href="https://php-tips.com/tags/array/index.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>CakePHP Hash::combine() でキーと値の組み合わせがずれる</title>
      <link>https://php-tips.com/2013/12/18/cakephp-hash-combine/</link>
      <pubDate>Wed, 18 Dec 2013 10:13:13 +0900</pubDate>
      <guid>https://php-tips.com/2013/12/18/cakephp-hash-combine/</guid>
      <description>&lt;p&gt;CakePHP 2.2以降で利用できる&lt;a href=&#34;http://book.cakephp.org/2.0/ja/core-utility-libraries/hash.html#Hash::combine&#34;&gt;Hashクラスのcombineメソッド&lt;/a&gt;には以下の罠があります。&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Code:&lt;/strong&gt;&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;
&lt; ?php
$data = [
	[
		&#39;id&#39; =&gt; 1,
		&#39;title&#39; =&gt; &#39;first title&#39;,
		&#39;body&#39; =&gt; &#39;first content&#39;
	],
	[
		&#39;id&#39; =&gt; 3,
		&#39;title&#39; =&gt; &#39;second title&#39;,
		&#39;body&#39; =&gt; &#39;second content&#39;,
		&#39;more&#39; =&gt; &#39;second more content&#39;
	],
	[
		&#39;id&#39; =&gt; 5,
		&#39;title&#39; =&gt; &#39;third title&#39;,
		&#39;body&#39; =&gt; &#39;third content&#39;,
		&#39;more&#39; =&gt; &#39;third more content&#39;
	],
];

$results = Hash::combine($data, &#39;{n}.id&#39;, &#39;{n}.more&#39;);

&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;この場合、$resultsは以下の値になることを期待するでしょう。&lt;/p&gt;</description>
    </item>
  </channel>
</rss>
