Danny620 Posted December 26, 2010 Share Posted December 26, 2010 i have a function that trims all post data $trimmed = array_map('trim', $_POST); however because i am subminting a post array like [locations] => Array ( [0] => Oldham [1] => Royton [2] => Delph [3] => Cheadle ) it gives me an error saying An error occurred in script 'C:\xampp\htdocs\admin\create_listing.php' on line 23: trim() expects parameter 1 to be string, array given how can i stop this all other data is posted in a string however the locations one is posted in an array Quote Link to comment Share on other sites More sharing options...
johnny86 Posted December 26, 2010 Share Posted December 26, 2010 You could use this function to trim multi-dimensional arrays: <?php function trimDeep($val) { return (is_array($val)) ? array_map("trimDeep", $val) : trim($val); } ?> Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.