Input value 0 = empty?

Dannyboy

New Member
I have a page where you register your dog, and I want all these fields to be required:\[code\]$required_fields = array('name', 'age', 'gender', 'breed', 'size');foreach ($_POST as $key => $value) { if (empty($value) && in_array($key, $required_fields) === true) { $errors[] = 'All fields marked with * are required.'; break 1; }}\[/code\]The problem is, that if someone enters 0 (which I instruct them to do if the dog is a puppy), the submission seems to read that field as empty (giving me this error). I have checks further down removing any none integers etc., but the best solution and easiest form for users I still think is having them being able to enter 0 as a value. Anyway, is there any way I can make my php code read the value as not null?
 
Back
Top