I have an method in Code Igniter, and want access using this URL "kuesioner/test/school_id/6/parent_id/7" I using _remap function to dynamic order of params in URL. Code from this. This is my code :
public function test($school_id, $parent_id)
{
echo "<pre>";
print_r($schoold_id);
print_r($parent_id);
echo "</pre>";
}
public function _remap($method, $params)
{
$map = array();
for( $i = 1; $i < count( $params ); $i = $i + 2 )
{
$map[$params[$i-1]] = $params[$i];
}
if( $method[0] != '_' && method_exists( $this, $method ))
return $this->$method($map);
}
Getting error on my controller that said Missing argument 2 for Kuesioner::test() ($parent_id is missing), it return array of map into single variable $school_id in test controller.
print_r($school_id) exactly show
Array
(
[school_id] => 6
[parent_id] => 7
)
How to solve this, so that value can be put into every right variable..