Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3

Thread: batch trim?

  1. #1
    Regular Coder
    Join Date
    Sep 2004
    Posts
    713
    Thanks
    6
    Thanked 2 Times in 2 Posts

    batch trim?

    Code:
    	foreach($_POST as $k=>$v){
    		$k=trim($_POST[$k]);
    	}
    Hi,

    Apparantly my code is wrong, anybody has better solution?


    Regards
    XD
    flying dagger

  • #2
    Supreme Master coder! abduraooft's Avatar
    Join Date
    Mar 2007
    Location
    N/A
    Posts
    14,852
    Thanks
    160
    Thanked 2,223 Times in 2,210 Posts
    Blog Entries
    1
    PHP Code:
    foreach($_POST as $key=>$value)
         $
    $key=trim($value); 
    See www.php.net/language.variables.variable
    The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)

  • #3
    Regular Coder kokjj87's Avatar
    Join Date
    Sep 2008
    Location
    Singapore
    Posts
    279
    Thanks
    1
    Thanked 55 Times in 54 Posts
    With this method, all trim value are store back to the $_POST super global..
    PHP Code:
    $_POST array_map('trim'$_POST); 
    http://php.net/array_map


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •