配列の中身をデバッグ表示する簡単な方法は、print_r を使用する
ところが出力はだらだらと表示されるので見辛い。
例えば、$day が配列だとすると
print_r($day);
出力は、
Array ( [0] => Dummy [1] => 116 [2] => 16 [3] => 55 [4] => 1 [5] => 12 [6] => 2 [7] => 80 [8] => 8 [9] => 34 [10] => 94 [11] => 6 [12] => 1 [13] => 72 [14] => 1 [15] => 44 [16] => 62 [17] => 59 [18] => 5 [19] => 77 [20] => 46 [21] => 21 [22] => 0 [23] => 57 [24] => 84 [25] => 152 [26] => 3 [27] => 11 [28] => 19 [29] => 19 [30] => 0 [31] => 0 )
このように非常に見辛いので、<pre>タグで囲んでみる
echo "<pre>";print_r($day);
echo "</pre>";
すると出力は、
Array ( [0] => Dummy [1] => 116 [2] => 16 [3] => 55 [4] => 1 [5] => 12 [6] => 2 [7] => 80 [8] => 8 [9] => 34 [10] => 94 [11] => 6 [12] => 1 [13] => 72 [14] => 1 [15] => 44 [16] => 62 [17] => 59 [18] => 5 [19] => 77 [20] => 46 [21] => 21 [22] => 0 [23] => 57 [24] => 84 [25] => 152 [26] => 3 [27] => 11 [28] => 19 [29] => 19 [30] => 0 [31] => 0 ) となり、非常に見やすくなる。
0 件のコメント:
コメントを投稿