2

I have following code:

    public function actionsdf($id){
        $dsf=UserLog::model()->findByPk($id);
        $decode=$dsf->text;
        var_dump($decode=$dsf->text);
        $res=CJSON::decode($decode);
        var_dump($res);

    }

The result of var_dump($decode=$dsf->text);is

string(103) "{"text":"LOG_EVENT_MEMBERSHIP_FORM_SENT {time}{form_id}","params":{"{time}":"11:38","{form_id}":"402"}}"

and the result of decoded json(var_dump($res);)is

array(2) { ["text"]=> string(46) "LOG_EVENT_MEMBERSHIP_FORM_SENT {time}{form_id}" ["params"]=> array(2) { ["{time}"]=> string(5) "11:38" ["{form_id}"]=> string(3) "402" } }

I need to retrieve only 402itself from form_d(where form_id=402). How can I do it?

Bizley
  • 17,392
  • 5
  • 49
  • 59
phpdev
  • 511
  • 4
  • 22

1 Answers1

1

Should be ["params"]["{form_id}"]

    $res=CJSON::decode($decode);
    var_dump($res);

    var_dump( $res["params"]["{form_id}"] );
ScaisEdge
  • 131,976
  • 10
  • 91
  • 107