简体   繁体   English

php从php URL中删除正斜杠

[英]php remove forward slash from php URL

I've tried everything I can find to remove the slashes that are being added to this: 我已经尝试了所有可以删除的添加到此斜杠的内容:

$attribute = Mage::getSingleton('eav/config')->getAttribute('catalog_product', 'c2c_used_by_game');
if ($attribute->usesSource()) {
$options = $attribute->getSource()->getAllOptions(false);
echo ('<form method="post">');
echo ('<select onChange="window.location.href=this.value">');
foreach ($options as $option)

    {
        echo '<option value="'.Mage::getUrl('catalogsearch/advanced/result',array ('?c2c_used_by_game='=>$option['value'])).'">'.$option['label'].'</option>';
    }   
echo ('</select>');
echo ('</form>');
}

So that's outputing a select dropdown that creates a link such as on here . 因此,这将输出一个select下拉列表,该下拉列表将创建一个链接,例如on here

I need one stinking slash removed after the equal sign so its c2c_used_by_game=561 and I just can't figure it out. 我需要在等号后删除一个臭味斜杠,以便其c2c_used_by_game=561并且我无法弄清楚。

array ('?c2c_used_by_game='=>(str_replace('/','',$option['value'])))).

'">'.str_replace('/','',$option['label']).'</option>';

Use _query in the second parameter to construct query properly: 在第二个参数中使用_query正确构造查询:

Mage::getUrl('catalogsearch/advanced/result', array('_query' => array ('c2c_used_by_game' => $option['value'])));

More info on getUrl function usage can be found on the Magento Wiki page . 在Magento Wiki页面上可以找到有关getUrl函数用法的更多信息。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM