私はクラスを使用して行列を使用して計算を行っています。この場合は、次のようになります。各列の合計を取得します。
合計の出力は正しく、通知を非表示にすると問題は解決しますが、論理的には修正を好みます。
PHP 5.3では、この関数にいくつかの通知があります。
Notice: Undefined offset: 0
Notice: Undefined offset: 0
Notice: Undefined offset: 1
脚本
function sum()
{
foreach($this->numbers as $i => $rows)
{
foreach($rows as $j => $number)
{
$this->sum[0][$j] += $number; //notices here
}
}
$the_sum = new matrix($this->sum, 1, $this->get_num_columns());
return $the_sum;
}
マトリックス:
1 | 4
0.25 | 1
var_dump($this->numbers);
array
0 =>
array
0 => int 1
1 => float 4
1 =>
array
0 => float 0.25
1 => int 1
と
$this->get_num_columns() // 2
これらの通知を修正するアイデアはありますか?
ありがとう