0

I have following code in my controller:

$model=ChForms::model()->findByPk($id);
$decode= $model->json;
$res=CJSON::decode($decode);
var_dump($res);
return $this->render('index', array('model'=>$model, 'res'=>$res));

the result of var_dump($res) is:

["p_2"]=> string(4) "test" ["p_3"]=> string(1) "0" 

How can I call values of ["p_2"] and ["p_3"] in my view(e.g test, 0)

Alexandre Tranchant
  • 4,426
  • 4
  • 43
  • 70
phpdev
  • 511
  • 4
  • 22

1 Answers1

1

CJSON::decode() returns an array by default. Since you are passing $res into your view you can access the required fields via $res["p_2"] and $res["p_3"].

topher
  • 14,790
  • 7
  • 54
  • 70