使用print_r($data)输出结果为Array
(
    [0] => stdClass Object
        (
            [color_item_no] => 1
            [color_name] => sdf
            [size_item_no] => 1
            [size] => S
            [jar_no] => 45
            [qty] => 45
            [stand_wgt] => 
            [qty_unit] => 1
        )    [1] => stdClass Object
        (
            [color_item_no] => 1
            [color_name] => sdf
            [size_item_no] => 2
            [size] => M
            [jar_no] => 45
            [qty] => 45
            [stand_wgt] => 
            [qty_unit] => 1
        )    [2] => stdClass Object
        (
            [color_item_no] => 1
            [color_name] => sdf
            [size_item_no] => 3
            [size] => L
            [jar_no] => 45
            [qty] => 4
            [stand_wgt] => 
            [qty_unit] => 1
        ))我使用
echo $data[0]['size']
提示错误,不然该怎么访问呢?

解决方案 »

  1.   

    顺便问一下,那该如何添加一个字段到这个数组中??
    Array 

        [0] => stdClass Object 
            ( 
                [color_item_no] => 1 
                [color_name] => sdf 
                [size_item_no] => 1 
                [size] => S 
                [jar_no] => 45 
                [qty] => 45 
                [stand_wgt] => 
                [qty_unit] => 1 
                [id] => 123 
            ) 

    像上面那样
      

  2.   

    $obj=new stdClass();
    $obj>size=111;//可以赋其他值值
    $a[]=$obj;
      

  3.   

    实在太感谢了...
    刚学PHP,PHP的数组和别的语言不大一样...实在搞得头痛...