Re: my checkbox array striped ?
| From: | Marek Kilimajer | Date: | Wed, 03 Mar 2004 23:46:10 +0000 |
| Subject: | Re: my checkbox array striped ? | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-179388@lists.php.net to get a copy of this message | ||
adwinwijaya wrote:
Hi all, I have a script like this: in html <form name="form" action="process.php" method="post">Both trim and stripTags take a string as an argument and return a string. So each $value is converted to a strig, if you look into the manual, if an array is converted to a string the result is "Array". You need a recursive function that takes an array as an argument and trims and striptags every element of the array, unless the element is an array itself, in this case it calls itself with the array element as the argument.<input name="type[]" type="checkbox" id="type[]" value="1" checked> <input name="type[]" type="checkbox" id="type[]" value="2" > <input name="type[]" type="checkbox" id="type[]" value="3" > <input name="type[]" type="checkbox" id="type[]" value="4" > <input name="type[]" type="checkbox" id="type[]" value="5" > <input type="text" name="xyz"> <input type="submit" name="Submit" value="GO"></form> and in process.php I have: <?php function stripTags($value){ if(isset($value))return strip_tags($value);} if(isset($_POST)){foreach($_POST as $key=>$value){ $_POST[$key] = trim($value); $_POST[$key] = stripTags($value) ; }}