How to create array and use in template

Please review below array:
I want to use function to return this array and then need to use in template.
Please advice.

Array
(
[0] => Array
(
[ID] => 76
[ShopifyID] => 299410194589
[ProductsCt] => 0
[SortOrder] => 0
[CollectionActive] => 0
[ProductsPerPage] => 0
[FileID] => 0
[ClassName] => Swordfox\Shopify\Model\Collection
[LastEdited] => 2022-05-11 05:34:23
[Created] => 2022-05-10 10:22:10
[Title] => Books
[NavText] =>
[URLSegment] => books
[Content] =>
[OriginalSrc] =>
[Active] => 1
[Version] => 0
[ImageID] => 0
)

[1] => Array
    (
        [ID] => 77
        [ShopifyID] => 298652762269
        [ProductsCt] => 0
        [SortOrder] => 0
        [CollectionActive] => 0
        [ProductsPerPage] => 0
        [FileID] => 0
        [ClassName] => Swordfox\Shopify\Model\Collection
        [LastEdited] => 2022-05-11 05:34:47
        [Created] => 2022-05-10 10:23:27
        [Title] => Test
        [NavText] => 
        [URLSegment] => test
        [Content] => Test
        [OriginalSrc] => 
        [Active] => 1
        [Version] => 0
        [ImageID] => 0
    )

)

Assuming you’re writing your own array.

You could wrap the array in an ArrayData.

$yourArray = []; // ID => 77 etc
ArrayData(['Data' => $yourArray]);

Depending on your use case you can return the ArrayData or if in a controller for a page:

$data = new ArrayData(['Data' => $yourArray]);

return $this->customise($data)->renderWith('Layout/SomePage'); 

If that data is coming out of the database/model it’l be similar. For example

$product = Product::get_by_id($id);

if ( ! $product)
{
    return $this->httpError(404);
}
else
{
    $data = new ArrayData(
        [
            'Product' => $product,
            'Title' => $product->Title,
            'RelatedProducts' => Product::get()->exclude('ID', $product->ID)->limit(4)->sort('CIN7ModifiedDate DESC')
         ]
    );
}

return $this->customise($data)->renderWith('Layout/ProductViewPage');

In your template access is the same.

$Data.ID // should output 77. Product.Title etc