/ Published in: Perl
This is inspired by this http://www.cgi101.com/book/ch5/text.html so I'm using a similar example. In PHP you can combine a set of checkboxes into an array using square brackets like this:
Red Green Blue GoldPHP does not do this automatically but it's pretty simple to do if you filter by regular expressions.
Expand |
Embed | Plain Text
use CGI; $query = CGI::new(); my %fields_temp = $query->Vars; my %fields = (); if ( $key =~ /(.+)\[\]$/ ) { ## Handle PHP style array inputs $fields{$1} = $fields{$1} . ",". $fields_temp{$key}; } else{ $fields{$1} = $fields_temp{$key}; } } else { $fields{$key} = $fields_temp{$key}; } } unless ($key =~ /(.+)\[\]$/ ){ } }
You need to login to post a comment.
