...

View Full Version : batch trim?



xiaodao
03-15-2009, 01:17 PM
foreach($_POST as $k=>$v){
$k=trim($_POST[$k]);
}


Hi,

Apparantly my code is wrong, anybody has better solution?


Regards
XD

abduraooft
03-15-2009, 01:34 PM
foreach($_POST as $key=>$value)
$$key=trim($value);
See www.php.net/language.variables.variable

kokjj87
03-16-2009, 06:20 AM
With this method, all trim value are store back to the $_POST super global..

$_POST = array_map('trim', $_POST);
http://php.net/array_map



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum