http://localhostr.com/files/V1ruKKj/capture.png
I want to rewrite all these ifs to something more manageable for lots of form fields.
I know it's not right but I want to rewrite it to something like this:
$fields = array();
function infcheck($var)
{
if ( !empty( $var ) )
{
$fields[$var] = $var;
}
}
infcheck( $_POST['streetname'] );
infcheck( $_POST['city'] );
infcheck( $_POST['state'] );
Basically when I run infcheck() I want the output to look like this:
Assuming $_POST['streetname'] is "Circle Street"
streetname => "circle street"
for a full example:
$fields = array();
infcheck( $_POST['streetname'] );
infcheck( $_POST['city'] );
//would be:
$fields = array(streetname => 'Circle Street', city => 'New York City');
I guess what I'm having trouble with is keeping the name of the form when $_POST['formname']
is turned into a variable.