0

好的,这是一些代码

$highestRow = 16; // e.g. 10
$highestColumn = 'F'; // e.g 'F'

$highestColumnIndex = PHPExcel_Cell::columnIndexFromString($highestColumn); // e.g. 5


for ($row = 9; $row <= $highestRow; ++$row) {
$val=array(); //i have initialized the array
  for ($col = 1; $col <= $highestColumnIndex; ++$col) {
   $cell=$objWorksheet->getCellByColumnAndRow($col, $row);
   $val[]=$cell->getValue();

  }
echo $val[0] //from what is read from excel, it returns data like this 7563
}

数据在 Excel 工作表中之前、之前、B9拥有75B10拥有6B11拥有的情况3

读完后我echo $val[0] //output 7563

现在我想在结果中添加额外的数据,所以如果我echo $val[0]在添加信息后显示输出为

echo $val[0] //output average=75% ; rsd = 6%; n=3% instead of just 7563
4

2 回答 2

0

根据您拥有的数组类型,您可以直接将其编辑为字符串,也可以将其转换为字符串。

如果该值已经是一个字符串,您可以简单地进行字符串操作,您可以创建一个临时字符串或使用原始字符串并一次编辑它以进行回显,这取决于您喜欢什么。

$strTemp = "output average=substr($var[0],0,2)% ; "rsd =substr($var[0]%,2,1); n=substr($var[0]%,3,1);" //can also use $var[0] instead of strTemp

如果值是整数格式,您必须将值转换为字符串,然后您可以从那里继续。如果你不知道怎么做,我建议这个线程:Converting an integer to a string in PHP

另一件事,我建议将数字存储在数组的不同部分,这样更容易引用它们并将它们区分开来。

于 2013-06-30T15:12:23.507 回答
0
foreach ($k as $key=>$value) {
    echo $key."=".$value."; ";
}
于 2013-06-30T14:06:44.207 回答