[PHP] Recursion to sanitize user input

2004-10-08 Thread zooming
I'm trying to sanitize my user input. My sanitize function does not work if I send a variable that's an array. I'm using recursion to go through the array. The example below shows that $_POST['city'] works but $_POST['user'] doesn't work. The array comes back blank. Anyone see what's wrong

RE: [PHP] Recursion to sanitize user input

2004-10-08 Thread Yoed Anis
, not tested. Best, Yoed -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Sent: Friday, October 08, 2004 5:15 PM To: [EMAIL PROTECTED] Subject: [PHP] Recursion to sanitize user input I'm trying to sanitize my user input. My sanitize function does not work if I send

Re: [PHP] Recursion to sanitize user input

2004-10-08 Thread Curt Zirzow
* Thus wrote Yoed Anis: Simple your code should look like this: ... if ( is_array($userInput) ) { foreach ( $userInput as $key = $value ) { return sanitize( $value ); // needed to return it or else its not recurssive This is wrong, only the

Re: [PHP] Recursion to sanitize user input

2004-10-08 Thread Robet Carson
it should be this i think: foreach ( $userInput as $key = $value ) { $newvalue[] = sanitize( $value ); } return $newvalue // returns an array - since this is the only way to get all veriables from the function } else I could be wrong but the only way it

Re: [PHP] Recursion to sanitize user input

2004-10-08 Thread Robet Carson
this would probably be even better: foreach ( $userInput as $key = $value ) { $newvalue[$key] = sanitize( $value ); // reassign key with sanatized value } return $newvalue // return array with sanatized $key = $value pairs } else My 2 cents: -- PHP General Mailing

Re: [PHP] Recursion to sanitize user input

2004-10-08 Thread Comex
foreach ( $userInput as $key = $value ) { $newvalue[$key] = sanitize( $value ); } return $newvalue; -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php

Re: [PHP] Recursion to sanitize user input

2004-10-08 Thread zooming
Hi Comex Thanks! That worked! Robet you almost had it but missing the $key in $newvalue[$key]. - Original Message - From: Comex [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Friday, October 08, 2004 8:05 PM Subject: Re: [PHP] Recursion to sanitize user input foreach ( $userInput