Codeigniter URI段在值中嵌入了“/”

时间:2013-01-15 16:25:37

标签: php codeigniter

使用值中嵌入了“/”的URI段的最佳方法是什么? 例如,我传递的端口号看起来像“abc1 / 1”。

谢谢。

1 个答案:

答案 0 :(得分:1)

好问题BTW,

有很多方法可以解决您的问题。但我更喜欢使用:

$this->uri->uri_to_assoc();

我假设您的案例有以下网址:

http://localhost/nearest/nearest/index.php/welcome/testUri/x/1/abc1/1/gg

所以你可以在控制器中执行此操作:

$array= $this->uri->uri_to_assoc(3); // getting from third segment and after
var_dump($array);

将输出:

array (size=3)
  'x' => string '1' (length=1)
  'abc1' => string '1' (length=1) //here's your argument combined as key => value
  'gg' => boolean false

因此,您可以使用此“键,值”数组来获取细分。