On Jan 21, 2008 10:19 AM, Eric Butera <eric.butera@xxxxxxxxx> wrote: > I don't think making a single generic function to iterate over every > value in the GET/POST arrays is a very good idea. Each field on a > form can contain very different pieces of data that should be handed > quite differently. I know you did point out that "this is just an > example," but nonetheless your class is intended to iterate over > everything with a generic solution. i think applying trim() to all input is appropriate. > Say you have three fields: name, email, and comments textarea. On the > back end your script should know that the three different fields have > different character limits and they should also be validated > differently. The email should be checked to make sure it is a valid > email address. The two other fields can have constraints like the > name field has to be between 4 characters and a max of 64. Then the > comments has a minimum of 1 and a max of 65535. How do you accomplish > this with one blanket function without passing in a massive array of > options. the class i supplied could easily be extended to accept a such a configuration array, which i see no problem with either. its the same approach taken by one of the functions in the filter extension you mentioned. http://us2.php.net/manual/en/function.filter-input-array.php this was not designed to be some end-all-be-all solution, it was merely an example which illustrated primarily how to convert an array of values into first class variables. i was also unaware of the extract() function. > These libraries have many eyes on them and are tested pretty well. To > forego all this work and start your own really requires a bigger > effort than most people realize. probly, using existing, working tools is the best choice for most cases. taking code from somebody writing it at 2 in the morning might not be so smart ;) really, i was just trying to answer the question at hand, i believe i did that. [1] http://php.net/filter > [2] http://framework.zend.com/manual/en/zend.filter.html > [3] http://stubbles.net/wiki/Docs/Validators > thank you for the references, in particular, i was unaware of the filter extension, ill give that a closer look. -nathan