Get three-layer categories in magento 2

Please use the below code for that

How to update a specific value in array by JavaScriptexpoundsofttechsolution Get three-layer categories in magento 2

<?php
    $objectManager = \Magento\Framework\App\ObjectManager::getInstance();
    $subCategory = $objectManager->create('Magento\Catalog\Model\Category')->load($filterItemVal);
    $subCats = $subCategory->getChildrenCategories();

    foreach ($subCats as $subcat) {
        $_category = $objectManager->create('Magento\Catalog\Model\Category')->load($subcat->getId());
        $subcaturl = $subcat->getUrl();
        //echo $subcaturl;
		?>
       <ul class="category_main"><li>
	   <a href="<?= $subcat->getUrl(); ?>">
	   <?php echo $subcat->getName(); ?>  </a>
        <?php 
		$subCats1 = $_category->getChildrenCategories();
		foreach ($subCats1 as $subCats1n) {
		?>
        <ul class="category_main_sub">
		<li>
		<a href="<?= $subCats1n->getUrl(); ?>">
		<?php echo $subCats1n->getName(); ?>
		</a>
		</li>
		</ul>
		</li>
		</ul> 
        <?php 	
		}
		}
 ?>