Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我想请求有关如何在 getpath() 函数中提取特定值的信息。
目前我放置了以下信息:
<?php $currentCat = Mage::registry('current_category'); ?> <?php echo $currentCat->getPath()?>
和系统 echo 1/2/5 ,其中 1 是根的根,2 是目录根,5 是第一个简单类别。
我想仅提取该系列类别中的第三个值(本示例中的数字 5)以仅在页面中回显该信息,但我尝试了不同的方法但没有成功。
谢谢你。
爆炸(), 结束()
<?php echo end(explode("/", $currentCat->getPath())); ?>
你知道我是否可以设置一个值来始终检索那个 3 级别,无论我是否放在另一个子类别中
应该是这样的:
<?php $exp = explode("/", $currentCat->getPath()); echo $exp[2]; ?>
我建议你再看看explode() :)