我试图通过回显它们将两个类添加到td
。他们每次都包含一个类,但其他类可以改变。我跳上刚刚拥有所有类的数组中的如下功能...如何将两个值添加到类属性?
$StandClassArray = array('north stand', 'east stand', 'south stand', 'west stand');
注意,这些应该是两个单独的类,一个被称为“立”,一个被称为“北”或'south'等。所以td
都需要'站'级和4个指南针之一。
当我加入这个我td
以下....
$Side = 0 ; // This would have been passed to the function usually.
echo "<td class = $StandClassArray[$Side]>Text</td>";
我在浏览器中得到什么......
<td class = "north" stand = "">Text</td>
我试着做其他的方法,如...
echo "<td class = $StandClassArray[$Side] stand>Text</td>"; // Just the compass point in the array for this.
但它给出了相同的结果。
我很确定我以前曾经遇到过这个问题,但不记得如何解决它。
你需要用引号括您的HTML属性的值,特别是如果值包含一个空格。 –