数组操作object转json

//数组操作object转json

    public function shuju(){

    $sites = array(

    "runoob"=>array ( "菜鸟教程","http://www.runoob.com"),

    "google"=>array( "Google 搜索","http://www.google.com"),

    "taobao"=>array("淘宝","http://www.taobao.com")

    );

    echo "sites整个数组显示:
";

    var_dump($sites);echo "

";

    echo "sites单个值显示:
";

    echo $sites['runoob'][0]."

";


    $content = DB::table('ms_user')

            ->where('phone','=','13683288938')

            ->get();

    echo "content整个数组显示:
";

    var_dump($content);echo "

";


    echo "content转成json整个数组显示:
";

    $object = json_decode( json_encode( $content),true);

    var_dump($object);echo "

";


    echo "object单个值显示:
";

    echo $object[0]['id'] . "

";

    }

你可能感兴趣的:(数组操作object转json)