Problem with code
<blockquote>
  <p><strong>Possible Duplicate:</strong><br>
  <a href="http://stackoverflow.com/questions/7253581/problem-with-generating-string">Problem with generating string</a>  </p>
</blockquote>



<p>I have a group of 7 checkboxes as name="restriction[]" and value that I have assigned is Pos1 to POS7. Now I wish to generate string according to selected chechkboxes that is If 1st,5th, 7th boxes are selected it gives me sting as 1000101 if only first is selected it generate 1000000</p>

<p>My code is</p>

<pre><code>$restrictions = 7;

if(isset($_POST["submit"])) {
for ($i = 0; $i &lt; $restrictions; $i++) {   
    if(isset($_POST['restriction'][$i]) ){
    //echo $_POST['restriction'][$i];

      $val[] .= "1";
    } else {
      $val[] .= "0";
    }
}
echo $val;
}
</code></pre>

<p>Issue with this code is its generating string according to count of boxes selected. like if 1st and 5th is selected it generates 1100000. and I want to have 1000100</p>
