我有一个示例代码:
$array = array(
1 => "tag/gomobi.html",
2 => "game.html",
3 => "game.php",
4 => "game.html",
5 => "game/game-mobile/feed.html"
);
foreach ($array as $url) {
if(preg_match('/^((.*)\.html)(.*?)$/', $url, $matches)) {
echo $matches[1].'<br />';
}
}
但结果不能删除相同的值(game.html)
tag/gomobi.html
game.html
game.html
game/game-mobile/feed.html
如何修复它,结果是:
tag/gomobi.html
game.html
game/game-mobile/feed.html