Ibnu Habibie Ibnu Habibie - 6 months ago 9
HTML Question

How to add some php function inside html content

is it possible to do some function inside html content ?

here my code :

$parts = explode(',', 'option 1,option 2,option 3');
echo "<div class='form-group'>
<div class='col-sm-12'>
<label>label</label>
<select class='form-control' style='width: 100%;' name='select' placeholder='select'>
foreach($parts as $index=>$key) {
echo '<option>'.$key .'</option>';
}
</select>
</div>
</div>";

Answer

This won't work, you should do like this :

    $parts = explode(',', 'option 1,option 2,option 3');
    echo "<div class='form-group'>
        <div class='col-sm-12'>
        <label>label</label>
        <select class='form-control' style='width: 100%;' name='select' placeholder='select'>";
    foreach($parts as $index=>$key) {
        echo '<option>'.$key .'</option>';
    }
    echo "</select></div></div>";