跟进这个问题,我还有一个问题 - 我有两个相同的子键,但它们的键中有不同的数组组合variant
,例如,
Array
(
[1] => Array
(
[b] => Array
(
[quantity_request] => 1
[time_created] => 1339688613
[variant] => Array
(
[0] => x
[1] => y
)
)
)
[2] => Array
(
[b] => Array
(
[quantity_request] => 1
[time_created] => 1339688631
[variant] => Array
(
[0] => x
[1] => z
)
)
)
[3] => Array
(
[c] => Array
(
[quantity_request] => 1
[time_created] => 1339688959
[variant] => Array
(
)
)
)
)
那么,我怎样才能找到这个项目的匹配项,
[b] => Array
(
[quantity_request] => 1
[time_created] => 1339688631
[variant] => Array
(
[0] => x
[1] => z
)
)
function get_letter($letter,$array)
{
foreach($this->content as $k => $v)
{
if(array_key_exists($letter, $v))
{
return $k;
}
}
return false;
}
list($key,$different) = get_letter('b',array("x","z")); // return 1
如果有匹配,我想要这样的结果,
2
有任何想法吗?