Joined September 2012
·

kanuj bhatnagar

India
·
·

Posted to Check a 1D array for emptiness over 1 year ago

@darkmantiscs Because in the scenario I just mentioned above it won't work. There's a form with multiple name and email rows, and the user can add more via JS. These fields are named like such: name[] and email[]. If the user submits an empty form, isset/empty won't validate a list of emails/names that don't have any data in them. The name/email arrays will have keys equal to the number of rows, but all of them will have empty values.

Posted to Check a 1D array for emptiness over 1 year ago

Makes sense for a project I'm in right now, where the first validation has to be that the email field can't be empty. This acts as a first step of validation, and if it is, I simply return an error message. There will be a chance, atleast in our scenario where users will simply submit the form without filling in anything at all.

Posted to Check a 1D array for emptiness over 1 year ago

Because sometimes arrays' keys might exist, but no value(s) for those keys. Technically, the array isn't empty, but you can't use any of those keys' values. Case in point, a form with 10 email address fields, whose field names are kept as email[]. When this form is submitted, the $_POST['email'] array will be non-empty, but won't have any values for any of its keys.

Posted to Don't waste time on XML, json ftw over 1 year ago

It's also natively parsed by the browsers and is lighter than XML.

Achievements
63 Karma
3,207 Total ProTip Views
Interests & Skills