• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 351
  • Last Modified:

display array as checkbox list

Hi, I have a script as attached. When I run this only the last value is displayed as a checkbox but not the complete array. When I run print_r($ext) and array is displayed :Array ( [0] => 204 [1] => 205 [2] => 207 )  but the check box list only show 207. Help pls? Thank you.

 foreach($ext_array as $ext)
                $vSelect ='<input type="checkbox" id="extsn" name="extsn[]" value="' . $ext . '" />' . $ext.'<br />' ."\n";

Open in new window

2 Solutions
Robert SaylorSenior DeveloperCommented:

$vSelect ='<input type="checkbox" id="extsn" name="extsn[]" value="' . $ext . '" />' . $ext.'<br />' ."\n";


$vSelect .='<input type="checkbox" id="extsn" name="extsn[]" value="' . $ext . '" />' . $ext.'<br />' ."\n";
Ray PaseurCommented:
In PHP the single equal sign is the assignment operator.  The single dot is the concatenation operator.  When you use them together like this...

$a .= $b;

... Your telling PHP to take the string value of $b and append it to the rightmost end of the string value of $a, then replace $a with the resulting concatenation.  When you use just the equal sign like this...

$a = $b;

... you're telling PHP to take the data type and value of $b and overwrite $a with it.  It's a common mistake in PHP coding to accidentally omit some of this fiddly punctuation!
aej1973Author Commented:
Thank you very much for your quick response. It worked!
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now