消息关闭
    暂无新消息!
以下是json接口返回的数据,
stdClass Object
(
    [client_id] => 1
    [client_name] => aa
    [email] => example2@gmail.com
    [pass] => 1111
    [dob] => 1986-12-20
    [tob] => 00:00:00
)

请教,PHP 如何获取stdClass Object里面每个参数的值? 我要把各个参数的值分开保存到数据库,谢谢!

5个回答

︿ 3
谢谢楼上各位,那如何把以下对象[q]、[s]作为变量循环取出?
stdClass Object
(
    [status] => success
    [data] => Array
        (
            [0] => stdClass Object
                (
                    [q] => 111
                    [s] => aaa
                )

            [1] => stdClass Object
                (
                    [q] => 222
                    [s] => bbb
                )

            [2] => stdClass Object
                (
                    [q] => 333
                    [s] => ccc
                )

            [3] => stdClass Object
                (
                    [q] => 444
                    [s] => ddd
                )

            [4] => stdClass Object
                (
                    [q] => 555
                    [s] => eee
                )

            [5] => stdClass Object
                (
                    [q] => 555
                    [s] => ggg
                )
        )
    [type] => ics
)
︿ 3
$json = '你的json';
foreach($json->data as $v){
  echo $v->q . ' - ' . $v->s;
}