tags:

views:

38

answers:

1
$html=<<<html
<div>A:<input type="text" maxlength="40" size="8" name=option$i."1" value='$option1'/>(answer)</div><br/><br/>
html;
echo $html;

$i is a variable. For example, when $i=5, the value of name should be "option51".

So the HTML code should be

 <div>A:<input type="text" maxlength="40" size="8" name="option51" value='$option1'/>(answer)</div><br/><br/>

How to write the code?

A: 
<?php
    $name = 'option'.$i.'1';
    echo "<div>A:
        <input type='text' maxlength='40' size='8' name=$name value='$option1'/>
        (answer)
        </div><br/><br/>";
?>
carillonator
This is a solution!
Steven
Not a php guy but don't those quotes need to be escaped?
RCIX
you're right, single quotes will do, though.
carillonator