Wie zum verketten von Variablen und string im folgenden Szenario in PHP?

Habe ich folgenden PHP-code:

<?php
$rebate_no = 2;
echo "<table id='blacklistgrid_$rebate_no'  class='table table-bordered table-hover table-striped blacklistgrid'>
        <tr id='reb$rebate_no_1'>
          <td>
            <div class='btn-group'>
              <select name='product_id_$rebate_no[1]' id='product_id_$rebate_no_1' class='form-control prod_list'>
                <option value='1'>Alabama</option>
                <option value='2'>Alaska</option>
                <option value='3'>Arizona</option>
                <option value='4'>Arkansas</option>
                <option value='5'>California</option>
              </select>
            </div>
          </td>
        </tr>
      </table>";
?>

Im obigen code habe ich Probleme, in die Verkettung von Variablen und string auf folgenden Linien:

<tr id='reb$rebate_no_1'>
<select name='product_id_$rebate_no[1]' id='product_id_$rebate_no_1' class='form-control prod_list'>

Versuchte ich folgenden trick, aber es hat nicht funktioniert für mich.

<tr id='reb'.$rebate_no.'_1'>
<select name='product_id_$rebate_no[1]' id='product_id_'.$rebate_no.'_1' class='form-control prod_list'>

Wenn ich die Option in HTML-Quelle, die ich bin immer folgenden HTML-Code:

<tr id="reb" .2.'_1'="">
<select id="product_id_" class="form-control prod_list" .2.'_1'="" name="product_id_">

Eigentlich möchte ich den HTML-Code in folgenden gewünschten format:

<tr id='reb2_1'>
<select name='product_id_2[1]' id='product_id_2_1' class='form-control prod_list'>

Wie Sie diese erreichen? Vielen Dank im Voraus.

InformationsquelleAutor PHPLover | 2014-05-05
Schreibe einen Kommentar