1

それで、

私のコードでは、変数の1つにnullが含まれているため、問題を追跡するのがかなり難しくなりました。具体的には、何か奇妙なものが返されます。

以下は同じ配列のprint_rで、最初の配列print_r($array['key'][null])はキー付きで呼び出されnull、2番目の配列はキーprint_r($array['key'])なしで呼び出されnullます。最初の配列は何ですか?

初め

Array
(
    [parent_access] => 1
    [seasons] => Array
        (
            [1] => Array
                (
                    [parent_access] => 1
                    [rounds] => Array
                        (
                            [5] => Array
                                (
                                    [direct_access] => 1
                                )

                        )

                )

        )

)

2番目(以下の配列全体はhttps://gist.github.com/4679128で確認できます)

Array
(
    [1] => Array
        (
            [id] => 1
            [type] => competition
            [status] => 0
            [child_access] => 
            [direct_access] => 1
            [parent_access] => 
            [seasons] => Array
                (
                    [1] => Array
                        (
                            [id] => 1
                            [type] => season
                            [status] => 1
                            [child_access] => 1
                            [direct_access] => 
                            [parent_access] => 
                            [rounds] => Array
                                (
                                    [1] => Array
                                        (
                                            [id] => 1
                                            [type] => round
                                            [status] => 1
                                            [child_access] => 1
                                            [direct_access] => 
                                            [parent_access] => 
                                            [games] => Array
                                                (
                                                    [1] => Array
                                                        (
                                                            [id] => 1
                                                            [type] => game
                                                            [status] => 1
                                                            [child_access] => 1
                                                            [direct_access] => 
                                                            [parent_access] => 
                                                        )

                                                    [11] => Array
                                                        (
                                                            [id] => 11
                                                            [type] => game
                                                            [status] => 1
                                                            [child_access] => 1
                                                            [direct_access] => 
                                                            [parent_access] => 
                                                        )

                                                    [21] => Array
                                                        (
                                                            [id] => 21
                                                            [type] => game
                                                            [status] => 1
                                                            [child_access] => 1
                                                            [direct_access] => 
                                                            [parent_access] => 
                                                        )

                                                    [31] => Array
                                                        (
                                                            [id] => 31
                                                            [type] => game
                                                            [status] => 1
                                                            [child_access] => 1
                                                            [direct_access] => 
                                                            [parent_access] => 
                                                        )

                                                )

                                        )

                                    [5] => Array
                                        (
                                            [id] => 5
                                            [type] => round
                                            [status] => 1
                                            [child_access] => 1
                                            [direct_access] => 
                                            [parent_access] => 
                                            [games] => Array
                                                (
                                                    [5] => Array
                                                        (
                                                            [id] => 5
                                                            [type] => game
                                                            [status] => 1
                                                            [child_access] => 1
                                                            [direct_access] => 
                                                            [parent_access] => 
                                                        )

                                                    [15] => Array
                                                        (
                                                            [id] => 15
                                                            [type] => game
                                                            [status] => 1
                                                            [child_access] => 1
                                                            [direct_access] => 
                                                            [parent_access] => 
                                                        )

                                                    [25] => Array
                                                        (
                                                            [id] => 25
                                                            [type] => game
                                                            [status] => 1
                                                            [child_access] => 1
                                                            [direct_access] => 
                                                            [parent_access] => 
                                                        )

                                                    [35] => Array
                                                        (
                                                            [id] => 35
                                                            [type] => game
                                                            [status] => 1
                                                            [child_access] => 1
                                                            [direct_access] => 
                                                            [parent_access] => 
                                                        )

                                                )

                                        )

                                    [8] => Array
                                        (
                                            [id] => 8
                                            [type] => round
                                            [status] => 1
                                            [child_access] => 1
                                            [direct_access] => 
                                            [parent_access] => 
                                            [games] => Array
                                                (
                                                    [8] => Array
                                                        (
                                                            [id] => 8
                                                            [type] => game
                                                            [status] => 1
                                                            [child_access] => 1
                                                            [direct_access] => 
                                                            [parent_access] => 
                                                        )

                                                    [18] => Array
                                                        (
                                                            [id] => 18
                                                            [type] => game
                                                            [status] => 1
                                                            [child_access] => 1
                                                            [direct_access] => 
                                                            [parent_access] => 
                                                        )

                                                    [28] => Array
                                                        (
                                                            [id] => 28
                                                            [type] => game
                                                            [status] => 1
                                                            [child_access] => 1
                                                            [direct_access] => 
                                                            [parent_access] => 
                                                        )

                                                    [38] => Array
                                                        (
                                                            [id] => 38
                                                            [type] => game
                                                            [status] => 1
                                                            [child_access] => 1
                                                            [direct_access] => 
                                                            [parent_access] => 
                                                        )

                                                )

                                        )

                                    [10] => Array
                                        (
                                            [id] => 10
                                            [type] => round
                                            [status] => 1
                                            [child_access] => 1
                                            [direct_access] => 
                                            [parent_access] => 
                                            [games] => Array
                                                (
                                                    [10] => Array
                                                        (
                                                            [id] => 10
                                                            [type] => game
                                                            [status] => 1
                                                            [child_access] => 1
                                                            [direct_access] => 
                                                            [parent_access] => 
                                                        )

                                                    [20] => Array
                                                        (
                                                            [id] => 20
                                                            [type] => game
                                                            [status] => 1
                                                            [child_access] => 1
                                                            [direct_access] => 
                                                            [parent_access] => 
                                                        )

                                                    [30] => Array
                                                        (
                                                            [id] => 30
                                                            [type] => game
                                                            [status] => 1
                                                            [child_access] => 1
                                                            [direct_access] => 
                                                            [parent_access] => 
                                                        )

                                                    [40] => Array
                                                        (
                                                            [id] => 40
                                                            [type] => game
                                                            [status] => 1
                                                            [child_access] => 1
                                                            [direct_access] => 
                                                            [parent_access] => 
                                                        )

                                                )

                                        )

                                )

                        )

                    [2] => Array
                        (
                            [id] => 2
                            [type] => season
                            [status] => 1
                            [child_access] => 1
                            [direct_access] => 
                            [parent_access] => 
                            [rounds] => Array
                                (
                                    [2] => Array
                                        (
                                            [id] => 2
                                            [type] => round
                                            [status] => 1
                                            [child_access] => 1
                                            [direct_access] => 
                                            [parent_access] => 
                                            [games] => Array
                                                (
                                                    [2] => Array
                                                        (
                                                            [id] => 2
                                                            [type] => game
                                                            [status] => 1
                                                            [child_access] => 1
                                                            [direct_access] => 
                                                            [parent_access] => 
                                                        )

                                                    [12] => Array
                                                        (
                                                            [id] => 12
                                                            [type] => game
                                                            [status] => 1
                                                            [child_access] => 1
                                                            [direct_access] => 
                                                            [parent_access] => 
                                                        )

                                                    [22] => Array
                                                        (
                                                            [id] => 22
                                                            [type] => game
                                                            [status] => 1
                                                            [child_access] => 1
                                                            [direct_access] => 
                                                            [parent_access] => 
                                                        )

                                                    [32] => Array
                                                        (
                                                            [id] => 32
                                                            [type] => game
                                                            [status] => 1
                                                            [child_access] => 1
                                                            [direct_access] => 
                                                            [parent_access] => 
                                                        )

                                                )

                                        )

                                    [6] => Array
                                        (
                                            [id] => 6
                                            [type] => round
                                            [status] => 1
                                            [child_access] => 1
                                            [direct_access] => 
                                            [parent_access] => 
                                            [games] => Array
                                                (
                                                    [6] => Array
                                                        (
                                                            [id] => 6
                                                            [type] => game
                                                            [status] => 1
                                                            [child_access] => 1
                                                            [direct_access] => 
                                                            [parent_access] => 
                                                        )

                                                    [16] => Array
                                                        (
                                                            [id] => 16
                                                            [type] => game
                                                            [status] => 1
                                                            [child_access] => 1
                                                            [direct_access] => 
                                                            [parent_access] => 
                                                        )

                                                    [26] => Array
                                                        (
                                                            [id] => 26
                                                            [type] => game
                                                            [status] => 1
                                                            [child_access] => 1
                                                            [direct_access] => 
                                                            [parent_access] => 
                                                        )

                                                    [36] => Array
                                                        (
                                                            [id] => 36
                                                            [type] => game
                                                            [status] => 1
                                                            [child_access] => 1
                                                            [direct_access] => 
                                                            [parent_access] => 
                                                        )

                                                )

                                        )

                                    [9] => Array
                                        (
                                            [id] => 9
                                            [type] => round
                                            [status] => 1
                                            [child_access] => 1
                                            [direct_access] => 
                                            [parent_access] => 
                                            [games] => Array
                                                (
                                                    [9] => Array
                                                        (
                                                            [id] => 9
                                                            [type] => game
                                                            [status] => 1
                                                            [child_access] => 1
                                                            [direct_access] => 
                                                            [parent_access] => 
                                                        )

                                                    [19] => Array
                                                        (
                                                            [id] => 19
                                                            [type] => game
                                                            [status] => 1
                                                            [child_access] => 1
                                                            [direct_access] => 
                                                            [parent_access] => 
                                                        )

                                                    [29] => Array
                                                        (
                                                            [id] => 29
                                                            [type] => game
                                                            [status] => 1
                                                            [child_access] => 1
                                                            [direct_access] => 
                                                            [parent_access] => 
                                                        )

                                                    [39] => Array
                                                        (
                                                            [id] => 39
                                                            [type] => game
                                                            [status] => 1
                                                            [child_access] => 1
                                                            [direct_access] => 
                                                            [parent_access] => 
                                                        )

                                                )

                                        )

                                )

                        )

                )

        )

    [2] => Array
        (
            [id] => 2
            [type] => competition
            [status] => 1
            [child_access] => 
            [direct_access] => 
            [parent_access] => 
            [seasons] => Array
                (
                    [3] => Array
                        (
                            [id] => 3
                            [type] => season
                            [status] => 1
                            [child_access] => 
                            [direct_access] => 
                            [parent_access] => 
                            [rounds] => Array
                                (
4

1 に答える 1

2

http://ideone.com/pXRVKE

したがって、nullは空の文字列にキャストされます。

http://php.net/manual/en/language.types.array.php

nullは空の文字列にキャストされます。つまり、キーnullは実際には""の下に格納されます。

于 2013-01-31T01:24:47.167 に答える