how to simplify this code
I haven't been able to test it, but I'm fairly sure this will work:

$functionName = 'function';
switch(trim($this-&gt;uri-&gt;segment(5)))
{
    case 1: $functionName .= 'A'; break;
    case 0: $functionName .= 'B'; break;
    case 2: $functionName .= 'C'; break;
}
if($this-&gt;my_model-&gt;$functionName($this-&gt;uri-&gt;segment(8), $this-&gt;uri-&gt;segment(4)))
{
    $data['light'] = $this-&gt;my_model-&gt;data();
}
else
{
    show_error($this-&gt;my_model-&gt;errormessage());
}


For more information, see the PHP page on Variable Functions.