php-excel-reader操作excel中
$xls = new Spreadsheet_Excel_Reader();
$xls->setOutputEncoding('utf-8');
$xls->read($file_name);
for ($i=2; $isheets[0]['numRows']; $i++)
{
for($n = 1; $n sheets[0]['numCols']; $n++)
{
'$'.$xls->sheets[0]['cells'][1][$n] = $xls->sheets[0]['cells'][$i][$n];
}
}
红色那个部分是excel中第一行的标题,我做成了数据库中的字段了,如
title name
中国 成龙
所以在入库之前是需要
$title = '中国';
$name = '成龙';
现在是红色部分该如何写才能变成上面那样呢?
。。。才发完就自己解决了
'$'.$xls->sheets[0]['cells'][1][$n] = $xls->sheets[0]['cells'][$i][$n];
改成
${$xls->sheets[0][cells][1][$n]} = $xls->sheets[0]['cells'][$i][$n];
忘记大括号了。
PHP怎么学习?PHP怎么入门?PHP在哪学?PHP怎么学才快?不用担心,这里为大家提供了PHP速学教程(入门到精通),有需要的小伙伴保存下载就能学习啦!
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号