What techniques can be used in PHP to ensure that duplicate headlines are not displayed in a block of related news articles?

To ensure that duplicate headlines are not displayed in a block of related news articles, you can use an array to keep track of the headlines that have already been displayed. Before displaying a headline, check if it is already in the array. If it is not, display it and add it to the array. This way, each headline will only be displayed once.

$displayedHeadlines = array();

foreach($newsArticles as $article) {
    if(!in_array($article['headline'], $displayedHeadlines)) {
        echo $article['headline'];
        $displayedHeadlines[] = $article['headline'];
    }
}