Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/codeigniter/3.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 Codeigniter为分页目的编辑uri段_Php_Codeigniter - Fatal编程技术网

Php Codeigniter为分页目的编辑uri段

Php Codeigniter为分页目的编辑uri段,php,codeigniter,Php,Codeigniter,我有一个urlhttp://localhost/basic/Logiciel/ab/current_page/10/date_from/1571691600000/date_to/1572382800000/time_from/30/time_to/60 我得到了当前的url和下一个页面,如: $cu = current_url(); $current_page = $this->input->get('current_page'); $next_page = (int)$curr

我有一个url
http://localhost/basic/Logiciel/ab/current_page/10/date_from/1571691600000/date_to/1572382800000/time_from/30/time_to/60

我得到了当前的url和下一个页面,如:

$cu = current_url();
$current_page = $this->input->get('current_page'); 
$next_page = (int)$current_page + 1;
我想编辑
$current_page
,并将其设置为我选择的变量。uri或input类中是否有一个函数允许我更改uri段以形成新的url,或者我必须解析url并将url分解为数组,就像我不使用codeigniter时那样

$parse_cu = parse_url($url, PHP_URL_QUERY);
parse_str($parse_cu, $cu_arr);
$cu_arr['current_page'];

这里必须使用CodeIgniter的URI类

URI类有两个方法,例如
segment()
URI\u to\u assoc()
assoc\u to\u URI
,它们可以让您完全执行所需的操作


这里必须使用CodeIgniter的URI类

URI类有两个方法,例如
segment()
URI\u to\u assoc()
assoc\u to\u URI
,它们可以让您完全执行所需的操作

使用,您可以使用:

吸气剂:

$arr=($this->uri->uri_to_assoc());
哪个输出

Array
(
    [current_page] => 10
    [date_from] => 1571691600000
    [date_to] => 1572382800000
    [time_from] => 30
    [time_to] => 60
)
因此,获取“当前页面”:

    $arr=$this->uri->uri_to_assoc();
    $cp=$arr['current_page'];
并构建新的uri字符串:

    $arr1=$arr;
    $arr1['current_page']=$cp+1;
    echo $this->uri->assoc_to_uri($arr1);
(其中+1可以代表任何+var),其输出:

current_page/11/date_from/1571691600000/date_to/1572382800000/time_from/30/time_to/60
使用,您可以使用:

吸气剂:

$arr=($this->uri->uri_to_assoc());
哪个输出

Array
(
    [current_page] => 10
    [date_from] => 1571691600000
    [date_to] => 1572382800000
    [time_from] => 30
    [time_to] => 60
)
因此,获取“当前页面”:

    $arr=$this->uri->uri_to_assoc();
    $cp=$arr['current_page'];
并构建新的uri字符串:

    $arr1=$arr;
    $arr1['current_page']=$cp+1;
    echo $this->uri->assoc_to_uri($arr1);
(其中+1可以代表任何+var),其输出:

current_page/11/date_from/1571691600000/date_to/1572382800000/time_from/30/time_to/60

使用segment()怎么样?你的意思是
$this->uri->segment(3,$var)$var将返回,因此可能不是您想要实现的。关于如何使用段(),请参见?您的意思是
$this->uri->段(3,$var)$var将返回,因此可能不是您想要实现的。将url转换为数组是最简单的部分。如何使用变量集生成url:?您可以看到如何将此方法称为
assoc\u to\u uri()
。使用这个方法更新关联数组中的uri部分,并使用该方法生成最终的uri。将url转换为数组是最简单的部分。如何使用变量集生成url:?您可以看到如何将此方法称为
assoc\u to\u uri()
。使用该方法更新关联数组中的uri部分,并使用该方法生成最终uri。