-3

这是代码

for($r=1; $r<=10; $r++){
if($shirt_info[$r][0]!='Select One')
{
    echo '<div class='shirtinfo'>Order $r: </div>';
    echo '<div class='shirtinfo'>Size: '.$shirt_info[$r][0].'</div>';
    echo '<div class='shirtinfo'>Price: '.$shirt_info[$r][1].'</div>';
    echo '<div class='shirtinfo'>Qty: '.$shirt_info[$r][2].'</div>';
    echo '<div class='shirtinfo'>SPE: '.$shirt_info[$r][5].'</div>';
    echo '<div class='shirtinfo'>LIA: '.$shirt_info[$r][6].'</div>';
    echo '<div class='shirtinfo'>Vendor: '.$shirt_info[$r][7].'</div>';
    echo '<div class='shirtinfo'>Style: '.$shirt_info[$r][8].'</div>';
    echo '<div class='shirtinfo'>Color: '.$shirt_info[$r][9].'</div>';
    echo '<div style='clear:both;'></div>';
}}

这就是结果http://www.redfivedesigns.com/screenshot2.jpg

4

2 回答 2

1

来自php手册:

有关字符串如何表现的信息,尤其是关于单引号、双引号和转义序列的使用,请参阅手册类型部分中的字符串条目。

http://www.php.net/manual/en/language.types.string.php

// Outputs: Arnold once said: "I'll be back"
echo 'Arnold once said: "I\'ll be back"';
于 2012-09-02T16:32:22.063 回答
0

转义引号或使用双引号:

逃脱:

echo '<div class=\'shirtinfo\'>Order $r: </div>';
echo '<div class=\'shirtinfo\'>Size: '.$shirt_info[$r][0].'</div>';
echo '<div class=\'shirtinfo\'>Price: '.$shirt_info[$r][1].'</div>';
echo '<div class=\'shirtinfo\'>Qty: '.$shirt_info[$r][2].'</div>';
echo '<div class=\'shirtinfo\'>SPE: '.$shirt_info[$r][5].'</div>';
echo '<div class=\'shirtinfo\'>LIA: '.$shirt_info[$r][6].'</div>';
echo '<div class=\'shirtinfo\'>Vendor: '.$shirt_info[$r][7].'</div>';
echo '<div class=\'shirtinfo\'>Style: '.$shirt_info[$r][8].'</div>';
echo '<div class=\'shirtinfo\'>Color: '.$shirt_info[$r][9].'</div>';
echo '<div style=\'clear:both;\'></div>';

使用双引号:

echo '<div class="shirtinfo">Order $r: </div>';
echo '<div class="shirtinfo">Size: '.$shirt_info[$r][0].'</div>';
echo '<div class="shirtinfo">Price: '.$shirt_info[$r][1].'</div>';
echo '<div class="shirtinfo">Qty: '.$shirt_info[$r][2].'</div>';
echo '<div class="shirtinfo">SPE: '.$shirt_info[$r][5].'</div>';
echo '<div class="shirtinfo">LIA: '.$shirt_info[$r][6].'</div>';
echo '<div class="shirtinfo">Vendor: '.$shirt_info[$r][7].'</div>';
echo '<div class="shirtinfo">Style: '.$shirt_info[$r][8].'</div>';
echo '<div class="shirtinfo">Color: '.$shirt_info[$r][9].'</div>';
echo '<div style="clear:both;"></div>';

另外,我认为您的意思echo '<div class="shirtinfo">Order '.$r.': </div>';echo '<div class="shirtinfo">Order $r: </div>';

于 2012-09-02T16:36:49.857 回答