Welcome Guest, Not a member yet? Register   Sign In
How to do that?
#1

[eluser]7amza[/eluser]
hey dears ,
i use routes library to rewrite urls :
$route['(:any)-(:num)'] = "category/Select/$1/$2";
so the url will be like that :
base_url/Politic-3
but when i request : $this->uri->segment(2)
i get Politic-3 but i want get just Politic and if i request : $this->uri->segment(3) i will get 3
so can i do that?
//sorry for my bad english .
#2

[eluser]Twisted1919[/eluser]
If i were you , i wouldn't use routes .
I would create a function called select() and i would do like :
Code:
function select($uri=''){

if( preg_match('/([a-zA-Z0-9]+)-([0-9]+)/ix',$uri,$matches) ){
   $first = $matches[0];//politic
   $second= $matches[2];//3
}

}

or you can do it easier :
Code:
function select(uri=''){
  if( strpos($uri,'-') !== false ){
    $u = explode('-',$uri);
    $first = $u[0];//politic
    $second= $u[1];//3
  }
}

Don't use routes when you don't really need them .




Theme © iAndrew 2016 - Forum software by © MyBB