In Block:
protected $_storeManager;
public function __construct(
\Magento\Store\Model\StoreManagerInterface $storeManager,
)
{
$this->_storeManager = $storeManager;
}
public function storeView()
{
$groups = $this->_storeManager->getWebsite()->getGroups();
$storeViewName = [];
foreach ($groups as $key => $group) {
$stores = $group->getStores();
foreach ($stores as $store) {
$storeViewName[] = "".$store->getName()."";
}
}
return $storeViewName;
}
In Phtml:
$stores = $block->storeView();
$allStore = implode(" ",$stores);
print_r($allStore);
?>