【发布时间】:2012-06-05 19:45:14
【问题描述】:
我有以下功能,其目的是在数组树中过滤那些不符合搜索索引的元素并消除主题。我可以得到这个函数来带来想要的结果。
public function negativeKeywordsFilter($products, $negative_keywords){
$nk=explode(',',$negative_keywords);
foreach ($products['productItems'] as $product){
foreach ($product as $item){
foreach ($nk as $word){
if (stripos($item['name'],$word) !== false){
unset($item);
}
}
}
}
return $products;
}
我的数组如下所示:
array(
'page' => '1',
'items' => '234',
'items' => array(
'item' => array(
0 => array(
'name' => 'second',
'description' => 'some description'
)
)
)
)
)
如果名称与描述匹配,则应取消设置值。
【问题讨论】:
-
您能否提供预期输入和输出的示例?
-
@lgt 真的 你的数组看起来像吗?重复键?真的吗?
-
我要把我的输出放在这里
-
你知道我每天都在学习新事物