Exemple #1
0
 public function convert()
 {
     //Retrieve data from form
     $from_to = $_POST['from_to'] !== NULL ? $_POST['from_to'] : NULL;
     //default test data
     $d = array("name" => "Dalhatu Njidda", "task" => "Swipe Contest", "role" => array("Position" => "Executive Trainee", "Level" => "Junior"));
     $converter = new Convert();
     $data['result'] = null;
     if ($from_to === "jsontoarray") {
         $data['result'] = $converter->to_array($converter->to_json($d));
     } elseif ($from_to === "arraytojson" && is_array($d)) {
         $data['result'] = $converter->to_json($d);
     }
     $this->load->view('result', $data);
 }