Quick tip to trim all posted variables in PHP.
<?php
array_walk($_POST, 'trim_posted_variables');
/**
* function to trim all the posted variables.
*
* $param : value - as we are using array_walk function, first parameter
* in the used function should be value.
* index - second parameter should be key or index.
*/
function trim_posted_variables($value, $index){
$_POST[$index] = trim($value);
}
?>
<?php
array_walk($_POST, 'trim_posted_variables');
/**
* function to trim all the posted variables.
*
* $param : value - as we are using array_walk function, first parameter
* in the used function should be value.
* index - second parameter should be key or index.
*/
function trim_posted_variables($value, $index){
$_POST[$index] = trim($value);
}
?>
Thanks!!!!!!!!!!!! Enjoy Programming :)
Comments
Post a Comment
Thanks for your valuable comments.