[FX.php List] Problem re-submitting checkboxes to FM7

Andrew Denman adenman at tmea.org
Fri May 12 08:20:28 MDT 2006


I originally found this code on the php.net website, and it has turned out
to be very useful in situations like this:

function trim_array($x){
   if (is_array($x)) {return array_map('trim_array', $x);}
   return trim($x);
}
//Trim incoming data
$_POST = array_map('trim_array', $_POST);

This particular code will apply the trim() function to any variable, array,
or array with nested arrays you pass to it.  Just swap the trim() function
with the stripslashes() function and you're set!

Andrew Denman

-----Original Message-----
From: fx.php_list-bounces at mail.iviking.org
[mailto:fx.php_list-bounces at mail.iviking.org] On Behalf Of William Akey
Sent: Thursday, May 11, 2006 4:57 PM
To: FX.php Discussion List
Subject: Re: [FX.php List] Problem re-submitting checkboxes to FM7

Dan (and Dale),

Ahhhh... Well, you are both right as you probably knew you were :-). As you
have surmised, at that point in the processing, $FieldName is not an array,
which I was able to determine with the trusty function that I found:

echo is_array($FieldName) ? 'Array' : 'not an Array';

It turns out that I was passing all of the posted values through a
stripslashes() filter before extracting $FieldName from the POST array.

I am deeply appreciative of all the time you guys spent helping point me in
the right direction so I could see my error and correct it. Now using
implode() on $FieldName does the trick and all is very groovy.

Best regards

William






More information about the FX.php_List mailing list