Hi..
I'm not sure whats the array_merge doing here in this code?
I've read the mysql manual,but i just not sure what it is really means,so hope somebody could clear it out for me.
By the way this is the code :
if (isset($_POST['submit'])) { // Form has been submitted.
$errors = array();
// perform validations on the form data
$required_fields = array('username', 'password');
$errors = array_merge($errors, check_required_fields($required_fields, $_POST));
$fields_with_lengths = array('username' => 30, 'password' => 30);
$errors = array_merge($errors, check_max_field_lengths($fields_with_lengths, $_POST));
if ( empty($errors) ) {
....continue coding
}
wheres the check_required_fields and check_max_field_lengths are the function being made which is :
function check_required_fields($required_array) {
$field_errors = array();
foreach($required_array as $fieldname) {
if (!isset($_POST[$fieldname]) || (empty($_POST[$fieldname]) && $_POST[$fieldname] != 0)) {
$field_errors[] = $fieldname;
}
}
return $field_errors;
}
function check_max_field_lengths($field_length_array) {
$field_errors = array();
foreach($field_length_array as $fieldname => $maxlength ) {
if (strlen(trim(mysql_prep($_POST[$fieldname]))) > $maxlength) { $field_errors[] = $fieldname; }
}
return $field_errors;
}
actually,is that array_merge function in this code combine the return values from
check_required_fields and check_max_field_lengths function??
Thank You for helping :)