删除数组中的重复字符串
问题描述:
实际上,我在一个小型php脚本中工作,我正在使用简单的html dom为网站获取一些标签,无论如何这就是我正在使用的代码
In fact im working in a small php script , I'm using simple html dom to get some tags for a website, any way this is the code that i'm using
if( strpos($a, '#') !== false )
{
if( strpos($a, 'page') !== false ){}
else
{
if( strpos($a, '#') !== false ){}
else{
$items[] = $a;
}
}
}
我要删除重复的字符串在数组 $ items
中。
I want to delete duplicate string in the array $items
.
答
为什么不检查一下
if( strpos($a, '#') !== false )
{
if( strpos($a, 'page') !== false ){}
else
{
if( strpos($a, '#') !== false ){}
else{
if(!in_array($a, $items)){
$items[] = $a;
}
}
}
}