Inside of codeigniter controller I want to find whether uri_to_assoc values are set properly. If no I want to display a proper error message. So can someone please explain me how to find that. Please look example below,
when values set properly,
www.example.com/features/edit/8
when not set,
www.example.com/features/edit/
You have to check every value starting from the second segment.
In the controller:
public function _checkUriSegments(){
$params = $this->uri->uri_to_assoc(2);
var_dump($params);
foreach ($params as $key => $value) {
if(!$params[$key]){
return false;
}
}
return true;
}
public function edit(){
if(!$this->_checkUriSegments()){
echo 'wrong url !';
break;
}
// do some edits
}