codeigniter - Code Igniter, multiple passing parameters in method -


i have method in code igniter, , want access using url "kuesioner/test/school_id/6/parent_id/7" using _remap function dynamic order of params in url. code this. 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 controller said missing argument 2 kuesioner::test() ($parent_id missing), return array of map single variable $school_id in test controller.

print_r($school_id) show

  array   (     [school_id] => 6     [parent_id] => 7   ) 

how solve this, value can put every right variable..

always assign parameter default values 0 or else prevent unnecessary warning , errors.

public function test($school_id = 0, $parent_id = 0) {     echo "<pre>";     print_r($schoold_id);     print_r($parent_id);     echo "</pre>"; } 

Comments

Popular posts from this blog

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -

Trying to import CSV file to a SQL Server database using asp.net and c# - can't find what I'm missing -