Quote:
Originally Posted by HandCoder
perhaps:
PHP Code:
foreach ($_POST as &$field) { $field=sanitize_string($field); }
By using &$field instead of just $field - you reference each item in the $_POST array directly and apply the procedure to it, rather than a copy of it.
|
Interesting, I always thought foreach worked on a copy of the array only. I found out that the references only work in PHP >= 5
Quote:
Originally Posted by HandCoder
Perhaps also
PHP Code:
$field_list=array('field1','field2','field3'); foreach ($field_list as $field_name) { if (!isset($_POST[$field_name])) { $_POST[$field_name]=NULL; } }
This will set any missing fields to NULL
|
Note: Using a NULL value will evaluate as not set.
__________________
<mgraphic /> - I don't have a solution but I admire the problem.
|