我会在这里得到一些帮助:
我想做的事:
从以下位置删除 &itemsperpage=10:
http://localhost/thi/search/filter.html?type=featured&page=2&itemsperpage=10
并从中创建一个链接:
http://localhost/thi/search/filter.html?type=featured&page=2&itemsperpage=15
到目前为止,这是我想出的:
<a href="<?php echo url::site(url::current()) . http_build_query($_GET) // don't know what follows ?>"
我正在使用的框架功能是:
url::current() = 以控制器/动作格式返回当前 url
url::site() = 返回绝对 url 即http://localhost/site/controller/action
所以我必须从 http_build_query 函数的结果字符串中删除 '&itemsperpage'
但我在字符编码等方面遇到了麻烦!请帮忙!
所以这是字符编码的问题:
$needle = '&itemsperpage';
$querystring = http_build_query($_GET) . '<br/>';
// echo $querystring . '<br/>';
$pos = strpos($querystring, $needle);
$remove = substr($querystring, ((int)$pos));
echo substr(str_replace($remove, '', $querystring), 1); // returns ';'
我无法从 http_build_query 的结果中删除字符串 '&itemsperpage',即:'type=featured&page=2&itemsperpage=10' 和 strstr 之类的函数不输出任何内容