【发布时间】:2012-08-08 08:57:32
【问题描述】:
我正在尝试让这段代码正常工作,因为它正是我所追求的: http://www.reloadedpc.com/php/php-convert-csv-price-matrix-mysql-table/
虽然我得到了这个错误:
警告:array_merge() [function.array-merge]:参数 #1 不是 第 580 行 C:\xampp\htdocs\matrix\Csv.php 中的数组
警告:array_merge() [function.array-merge]:参数 #1 不是 第 580 行 C:\xampp\htdocs\matrix\Csv.php 中的数组
警告:array_merge() [function.array-merge]:参数 #1 不是 第 580 行 C:\xampp\htdocs\matrix\Csv.php 中的数组
致命错误:无法访问受保护的属性 Csv::$field_names in C:\xampp\htdocs\matrix\index.php 第 24 行
第 580 行是 Csv.php 的以下内容:
$this->contents[$line_nr][(int) $position] = array_merge( $this->contents[$line_nr][(int) $position] );
index.php 的第 24 行(和第 23 行)是:
//get the row of width increments
$stack = $csv->field_names;
Csv.php 文件可以在这里查看: http://hg.mijnpraktijk.com/csv-library/src/e4397b31002d/Csv.php
有什么建议吗?
谢谢各位。
-编辑- 整个代码块是:
foreach ( $this->contents as $line_nr => $line )
{
if ( array_key_exists( (int) $position, $this->contents[$line_nr] ) )
{
$return[$line_nr] = $this->contents[$line_nr][(int) $position];
unset( $this->contents[$line_nr][(int) $position] );
// reindex after removal
$this->contents[$line_nr][(int) $position] = array_merge($this->contents[$line_nr][(int) $position] );
}
}
它似乎取消了它。 $this->contents[$line_nr][(int) $position] 是矩阵的头部。
【问题讨论】:
-
你有没有调试过
$this->contents[$line_nr][(int) $position]实际上是什么?