【问题标题】:how to extract a specific link value (page number) from a pagination in codeigniter?如何从codeigniter中的分页中提取特定的链接值(页码)?
【发布时间】:2019-08-24 11:41:18
【问题描述】:

我想从控制器中的 codeigniter 分页中提取当前链接值并将其放入自己的变量中。

the usual pagination code...

$str_links = $this->pagination->create_links(); 
$data["links"] = explode(' ',$str_links );

with print_r($data["links"]);我打印了数组来检查我在里面找到了什么。

result:
( Array ( [0] => [1] => 1234NextLast › )  
( Array ( [0] => Previous1 [1] => 2345NextLast › )  
( Array ( [0] => Previous12 [1] => 3456NextLast › ) and so on

我想提取当前页码并将其添加到不同的变量中。

... [1] => 1
... [1] => 2
... [1] => 3 and so on

【问题讨论】:

    标签: codeigniter pagination extract


    【解决方案1】:

    你可以从url获取当前页码:

    $this->uri->segment(3);
    

    如果在第三段,你可以数段数或者我更喜欢这个:

    $segment_array = $this->uri->segment_array();
    $last_segment = end($segment_array);
    

    最后一段应该是您当前的页码。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2018-08-14
      • 2013-10-28
      • 2021-11-30
      • 1970-01-01
      • 1970-01-01
      • 2013-01-25
      • 2020-03-22
      相关资源
      最近更新 更多