Thank you for help. Anyway, i'm a student and i'm stuck making a function that does a simple empty() check on a key in a array. If it is empty() -> it will fill in the error and print it on a div element.
This is my code:
function validateData($data, $formErrors) {
if (empty($data)) {
$formErrors = 'name is required.';
}
echo $formErrors;
}
Executing the function:
$data = $_POST;
$formErrors = [];
// Elementen valideren
validateData($data['name'], $formErrors['name'] = '');
This is the thing that i want to achieve:
if (empty($data['surname'])) {
$formErrors['surname'] = 'Surname is required.';
}
Looks like it is not returning the value of that key or whatelse?
Thanks alot!