Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/296.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php magento getpath()提取值_Php_Magento_Extract - Fatal编程技术网

Php magento getpath()提取值

Php magento getpath()提取值,php,magento,extract,Php,Magento,Extract,我想请求有关如何在getpath()函数中提取特定值的信息 目前,我放置了以下信息: <?php $currentCat = Mage::registry('current_category'); ?> <?php echo $currentCat->getPath()?> 系统echo 1/2/5,其中1是根的根,2是目录根,5是第一个简单类别 我只想提取该系列类别中的第三个值(本例中的数字5),以便仅在页面中反映该信息,但我尝试了不同的方法,但没有成功 谢

我想请求有关如何在getpath()函数中提取特定值的信息

目前,我放置了以下信息:

<?php $currentCat = Mage::registry('current_category'); ?>
<?php echo $currentCat->getPath()?>

系统echo 1/2/5,其中1是根的根,2是目录根,5是第一个简单类别

我只想提取该系列类别中的第三个值(本例中的数字5),以便仅在页面中反映该信息,但我尝试了不同的方法,但没有成功

谢谢。



你知道我是否可以放置一个值,无论我是否放置在另一个子类别中,都始终检索该3级

应该是这样的:

<?php 
   $exp = explode("/", $currentCat->getPath());
   echo $exp[2];
?>


我建议您再看一次:)

太好了,它可以获得当前类别的值!你知道我是否可以放置一个值,无论我是否放置在另一个子类别中,都始终检索该3级?例:1/2/5/22/34,仅检索5?。brgds
<?php 
   $exp = explode("/", $currentCat->getPath());
   echo $exp[2];
?>