あなたがそのようにそれをしたいのなら...
複数の投稿入力があり、それらが検索専用であると仮定すると、次のようになります。
function search(){
$url = $this->uri->segment(2);
if(empty($url)){
if((isset($_POST) && (!empty($_POST))
{
$search_seg = '';
foreach($_POST as $k => $v){
// I always make sure to use the CI post w/
// TRUE set in the second param so as to XSS filter the user input
$var = $this->input->post($k, TRUE);
// Just incase the user input had a plus in it?
$var = str_replace('+', '%20', $var)
// Concatenate the search string
$search_seg .= $var . '+';
}
// Make the url, use substr() to strip the last + off the end
$search_seg = 'search/' . substr($search_seg, 0, -1);
/* Make sure CI's URL helper is enabled
$this->load->helper('url'); if it hasn't been loaded
This will give the illusion that the form post went to this URL,
thus doing what you're looking for... */
redirect($search_seg, 'location');
}else{
// There was no post, do whatever
}
}else{
$search_arr = explode('+', $url);
}
$ _GET配列を再作成し、CIスタイルのURLで使用する方法はいくつかありますが、上記は説明したとおりに実行されるはずですが、少し複雑です。
追加情報:
検索入力フィールドが1つだけで、たとえば、用語がスペースで区切られている場合は、次のように実行することをお勧めします(正規表現フィルタリングを使用して)...foreach($_POST as $k => $v)...
ループを次のように置き換えます。
$keywordinput = $this->input->post('keywords', TRUE);
$keywordinput = trim($keywordinput);
$keywords = explode(' ', $keywordinput);
foreach($keywords as $word){
if(!empty($word)){
$word = str_replace('+', '%20', $var)
$search_seg .= $word . '+';
}
}