Got an issue while displaying result array from foreach loop, because contain similiar words while looping so it would make it twice, the code like these below
foreach ($data['terms'] as $term) {
foreach ($data['links'] as $link) {
$html = file_get_html($link);
foreach ($html->find('div[class="item-content item-right"], div[class="col-custom left"],article') as
$konten) {
foreach ($konten->find('h4,h2') as $tags) {
foreach ($konten->find('a') as $urls) {
if (stripos($tags->plaintext, $term) !== false) {
$row['judul'] = $tags->plaintext;
$row['url'] = $urls->href;
$result[] = $row;
break;
}
}
}
}
}
}
foreach ($result as $res) {
echo $res['judul'] . '<br>';
echo $res['url'] . '<br>';
}
Result will displaying doubled because containing BRI words, but i want to the results not duplicate:
Konsisten Kelola Risiko, BRI Jaga Pencadangan secara Terukur Selama Pandemi
https: //wwwsuaracom/bisnis/2021/01/25/112538/
Rangkul Fans MLBB, BRI Terbitkan BRIZZI Special Edition Mobile Legend
https: //wwwsuaracom/bisnis/2021/01/25/112538/
Konsisten Kelola Risiko, BRI Jaga Pencadangan secara Terukur Selama Pandemi
https: //wwwsuaracom/bisnis/2021/01/25/073116/
Rangkul Fans MLBB, BRI Terbitkan BRIZZI Special Edition Mobile Legend
https: //wwwsuaracom/bisnis/2021/01/23/152844/
Pabrik Pakaian Branded Ini (PBRX) Siap Rilis Surat Utang Hampir Rp5 Triliun
https: //marketbisniscom/read/20210125/192/1347362/
IHSG Terkoreksi 1 Persen Lebih, Saham BBRI Tetap Diburu Asing
https: //marketbisniscom/read/20210125/192/1347362/
question from:
https://stackoverflow.com/questions/65880412/php-array-unique-for-duplicate-foreach-result 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…