get_topic_title() to retrieve the topic title as a string while in the loop.
To get the actual index keys of the
$topics array, you can use
array_keys, or if you want to actual topic IDs, you’d need to use
$topic->topic_id inside a foreach loop assigning