我正在尝试为url中包含的输入值的搜索结果创建一个url。除了"空白",一切都很好。
我现在得到这个:
localhost/admin/search-results/san diego-01/25/2016-01/27/2016 guest House-7
PS,"圣地亚哥"宾馆。我可以通过在值中添加"-"来手动更改下拉列表的值,但我担心这样做不会查询DB。位置文本输入也是如此。
控制器:
public function custom_search() {
$seg1 = $this->input->post('search[1]');
$seg2 = $this->input->post('search[2]');
$seg3 = $this->input->post('search[3]');
$seg4 = $this->input->post('search[4]');
$seg5 = $this->input->post('search[5]');
$segment_array = $this->input->post('search');
$segments = implode("-", $segment_array);
redirect('search-results/'.$segments);
}
尝试使用urlencode
函数。
当对要在查询URL的一部分,作为将变量传递给下一个的方便方式页
public function custom_search() {
$seg1 = $this->input->post('search[1]');
$seg2 = $this->input->post('search[2]');
$seg3 = $this->input->post('search[3]');
$seg4 = $this->input->post('search[4]');
$seg5 = $this->input->post('search[5]');
$segment_array = $this->input->post('search');
$segments = implode("-", $segment_array);
redirect('search-results/'.urlencode($segments));
}