I am new in PHP and ZEND. I read excel file and check values before insert them to database.
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...
I get this error:
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
$items[] = $cell->getValue();
$items[]=trim($items[]);
Try out with this
$items[] = trim($cell->getValue());
Remove the following line
$items[]=trim($items[]);
$item = $cell->getValue();
$item = trim($item);
if ($col != 2) {
$item = str_replace(array('-', ' '), "", $item);
if (!is_numeric($item)) {
$item = NULL;
}
}
$items[] = $item;
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.