Laravel 如何列印簡單的陣列
PHP中文网
PHP中文网 2017-05-16 16:54:55
0
2
512

laravel自備印dd()輸出有點看不懂

Collection {#279 ▼
  #items: array:7 [▼
    0 => Cate {#280 ▼
      +timestamps: false
      #guarded: array:1 [▶]
      #connection: null
      #table: null
      #primaryKey: "id"
      #perPage: 15
      +incrementing: true
      #attributes: array:5 [▶]
      #original: array:5 [▶]
      #relations: []
      #hidden: []
      #visible: []
      #appends: []
      #fillable: []
      #dates: []
      #dateFormat: null
      #casts: []
      #touches: []
      #observables: []
      #with: []
      #morphClass: null
      +exists: true
      +wasRecentlyCreated: false
    }
    1 => Cate {#281 ▶}
    2 => Cate {#282 ▶}
    3 => Cate {#283 ▶}
    4 => Cate {#284 ▶}
    5 => Cate {#285 ▶}
    6 => Cate {#286 ▶}
  ]
}

如何輸出 print_r簡單這樣的陣列?

[0] => Array
    (
        [id] => 1
        [pid] => 0
        [name] => 安徽省
        [son] => Array
            (
                [0] => Array
                    (
                        [id] => 3
                        [pid] => 1
                        [name] => 合肥市
                        [son] => Array
                            (
                                [0] => Array
                                    (
                                        [id] => 4
                                        [pid] => 3
                                        [name] => 长丰县
                                    )

                            )

                    )

                [1] => Array
                    (
                        [id] => 5
                        [pid] => 1
                        [name] => 安庆市
                    )

            )

    )

print_r列印輸出 會出現這個多餘的 如何簡化?

Illuminate\Database\Eloquent\Collection Object
(
    [items:protected] => Array
        (
            [0] => kyomini\Cate Object
                (
                    [timestamps] => 
                    [guarded:protected] => Array
                        (
                            [0] => submit
                        )

                    [connection:protected] => 
                    [table:protected] => 
                    [primaryKey:protected] => id
                    [perPage:protected] => 15
                    [incrementing] => 1
                    [attributes:protected] => Array
                        (
                            [id] => 1
                            [pid] => 0
                            [c_name] => 文章
                            [byname] => 
                            [sort] => 0
                        )

                    [original:protected] => Array
                        (
                            [id] => 1
                            [pid] => 0
                            [c_name] => 文章
                            [byname] => 
                            [sort] => 0
                        )

                    [relations:protected] => Array
                        (
                        )

                    [hidden:protected] => Array
                        (
                        )

                    [visible:protected] => Array
                        (
                        )

                    [appends:protected] => Array
                        (
                        )

                    [fillable:protected] => Array
                        (
                        )

                    [dates:protected] => Array
                        (
                        )

                    [dateFormat:protected] => 
                    [casts:protected] => Array
                        (
                        )

                    [touches:protected] => Array
                        (
                        )
PHP中文网
PHP中文网

认证0级讲师

全部回覆(2)
世界只因有你

http://php.net/manual/zh/function.var-export.php

http://php.net/manual/zh/function.var-dump.php

淡淡烟草味

print_r($obj->toarray());

熱門教學
更多>
最新下載
更多>
網站特效
網站源碼
網站素材
前端模板
關於我們 免責聲明 Sitemap
PHP中文網:公益線上PHP培訓,幫助PHP學習者快速成長!