Saturday, 15 September 2012

Trim All Posted Variables in PHP

Quick tip to trim all posted variables in 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 :)

No comments:

Post a Comment

Thanks for your valuable comments.