I had an HTML form that sent checkbox values to a Perl CGI script as an Array. However, since the site was rebuilt using mainly PHP, the checkbox array is handled differently. I have a PHP function that returns the form. It looks something like this:
<td>Profiles: </td>
<td><input type=\"checkbox\" value=\"oneconnect\" name=\"v1-profile[]\">OneConnect <br />
<input type=\"checkbox\" value=\"http\" name=\"v1-profile[]\">HTTP <br />
<input type=\"checkbox\" value=\"xforwardedfor\" name=\"v1-profile[]\">Xforwarded-for</td>
</tr>
I then send this to a Perl CGI script
use CGI qw(:standard);
my $q = new CGI;
my @profiles1 = $q->param("v1-profile");
When I try to print the elements of the array, I only see the word "Array" as the output.
foreach my $r (@profiles1) {
print "$r\n";
}
I have also tried a few things that did not work.
foreach my $r (@profiles1) {
foreach my $v (@$r) {
print "$v\n";
}
}
How would I access the elements of the "@profiles1" array? Thank you for the help!
ARRAY(0x27967ac)
? This is different fromArray
and means you have an array reference that simply needs dereferencing. – Borodin