2つのアレイを取得しています
Array
(
[0] => 1990
[1] => 1991
[2] => 1992
[3] => 1993
[4] => 1994
[5] => 1995
[6] => 1996
[7] => 1997
[8] => 1998
[9] => 1999
[10] => 2000
[11] => 2001
[12] => 2002
[13] => 2003
[14] => 2004
[15] => 2005
[16] => 2006
[17] => 2007
[18] => 2008
[19] => 2009
[20] => 2010
[21] => 2011
[22] => 2012
[23] => 2013
)
と
Array
(
[0] => Array
(
[year] => 2011
[conv_value] => 80
)
[1] => Array
(
[year] => 2012
[conv_value] => 95
)
[2] => Array
(
[year] => 2004
[conv_value] => 60
)
[3] => Array
(
[year] => 2000
[conv_value] => 55
)
)
1番目の配列の2番目の配列から年の一致を検索し、正確に長さのある新しい配列を作成する1番目の配列の検索は次のようになります。
年が見つかった場合は、新しいインデックスが設定されます。名前conv_valueには、2番目の配列インデックスconv_valueの値が含まれ、見つからなかった場合は、conv_valueは空になります。
このような
Array
(
[0] => Array
(
[year] => 1990
[conv_value] =>
)
[1] => Array
(
[year] => 1991
[conv_value] =>
)
[2] => Array
(
[year] => 1992
[conv_value] =>
)
[3] => Array
(
[year] => 1993
[conv_value] =>
)
[4] => Array
(
[year] => 1995
[conv_value] =>
)
[5] => Array
(
[year] => 1996
[conv_value] =>
)
[6] => Array
(
[year] => 1997
[conv_value] =>
)
[7] => Array
(
[year] => 1998
[conv_value] =>
)
[8] => Array
(
[year] => 1999
[conv_value] =>
)
[9] => Array
(
[year] => 2000
[conv_value] => 55
)
[10] => Array
(
[year] => 2001
[conv_value] =>
)
[11] => Array
(
[year] => 2002
[conv_value] =>
)
[12] => Array
(
[year] => 2003
[conv_value] =>
)
[13] => Array
(
[year] => 2004
[conv_value] => 95
)
[14] => Array
(
[year] => 2005
[conv_value] =>
)
[15] => Array
(
[year] => 2006
[conv_value] =>
)
[16] => Array
(
[year] => 2007
[conv_value] =>
)
[17] => Array
(
[year] => 2008
[conv_value] =>
)
[18] => Array
(
[year] => 2009
[conv_value] =>
)
[19] => Array
(
[year] => 2010
[conv_value] =>
)
[20] => Array
(
[year] => 2011
[conv_value] => 80
)
[21] => Array
(
[year] => 2012
[conv_value] => 95
)
[22] => Array
(
[year] => 2013
[conv_value] =>
)
)
スクリプトを作成しました
for ( $y = 0; $y < sizeof($cc); $y++ ){
for ( $z = 0; $z < sizeof($years); $z++ ){
if ($cc[$y]['year'] == $years[$z]) {
echo 'Hay<br>';
}else{
echo 'Nahee hay<br>';
}
}
}
しかし、結果は得られませんでした。
どこでミスをしているの?