How can i automatically HREF the articles of my MongoDB database to each article specific page?

Hello everyone i’m working on a site which is more a DB project that anything else currently i mainly use my mongoDB database to show the previews of those articles after querring them with these functions (which are in 2 different files)


//this one is from the functions file which i load in all the various pages of the site
function article_recordset(){
   

require 'vendor/autoload.php';

$client = new MongoDBClient("mongodb://localhost:27017");
$i = 0;
$SiteArticles = $client->SiteArticles;
$articoli=$SiteArticles->Articles;
$cursor = $articoli->find();
return $cursor;

    foreach ($cursor as $articolo) {      
        $recordset = array(
            $i=$i+1 => array(
                "title" => $articolo["title"],
                "description" => $articolo["content"],
                "article" => "",
            )
        );
    }

}    

//this is the index.php file so the homepage where i display the articles which i stored into an array and then i display with an echo later


include("funzioni.inc.php");//name of the functions file

$ARR_articles = article_recordset();

$STR_article = NULL;

foreach($ARR_articles as $index => $article){
    $STR_article .= get_article_item_html(
        $img_path = "img/article/".$index.".jpg", 
        $title = $article["title"], 
        $description = $article["content"]
    );
}

The display works fine and all but what i’m trying to do is to HREF each displayed article preview to their own article page

So article 1 is displayed and is linked to the page of localhost/folder/article1.php for exhample

now the href i want to do is somewhat automatic so it links to each article page which i manually created already just like it does the foreach for the query of all the article contents

so like it’s gonna store each article in the array which i display later while also like setting an href to each one

eg

Query article 1, store into array, display that array content for article 1 and href it to it’s own page
and so on for each article

Note: I want to “”automatize”” just the HREF of each querried article not automatise the article page creation since i have those pages already created and it’s for a small project and nothing too serious