如何在php数组索引中进行数学运算


how to do math operation in php array index

这是我的代码

echo "<table border='"5'" cellpadding='"10'">";
for ($i=0; $i < ceil(count($files1)/5); $i++)
{
echo "<tr>";
for ($c=0; $c<5; $c++)
{
  echo "<td>$files1[$i+$c]</td>";
}
echo "</tr>";
}
echo "</table>"; 

目标是将数组值显示到一个包含5列的表中。然而,php不允许我在的这一部分做数学运算

$files1[$1+$c]

这里似乎不允许进行数学运算。有人能帮忙吗?

除了Kolink的答案,这也会起作用:

print "Result: {$array[$x+$y]}";

演示

购买前试用

不要使用插值,使用串联:

"blah blah blah ".$somearray[$var1 + $var2]." more blah";