我是PHP和ZEND的新手。在将数据插入数据库之前,我读取了excel文件并检查了值。
for ($row = 2; $row <= $highestRow; ++$row) {//MM
$items = array();
for ($col = 1; $col < $highestColumnIndex; ++$col) {
$cell = $objWorksheet->getCellByColumnAndRow($col, $row);
$items[] = $cell->getValue();
$items[]=trim($items[]);
if ($col = 2) { continue;
}else{
$items[]=preg_replace("/^[-\s]$/", "", $items);// or abs($items[]);
if(!is_numeric ($items)){
$items[]=null;
}
}
}
$rating = mysql_escape_string($items[0]);
and so on...
我收到此错误:
Fatal error: Cannot use [] for reading in C:\Program Files\Apache Software Foundation\httpd-2.2.21\htdocs\project\zend\application\modules\admin\models\bankranking\BankRankAdmin.php on line 204
答案 0 :(得分:0)
$items[] = $cell->getValue();
$items[]=trim($items[]);
试试这个
$items[] = trim($cell->getValue());
删除以下行
$items[]=trim($items[]);
答案 1 :(得分:0)
$item = $cell->getValue();
$item = trim($item);
if ($col != 2) {
$item = str_replace(array('-', ' '), "", $item);
if (!is_numeric($item)) {
$item = NULL;
}
}
$items[] = $item;