php怎样原样输出变量名称和值

WBOY
Release: 2016-06-23 13:40:01
Original
1783 people have browsed it

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];

忘记大括号了。

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template