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 Link to comment https://forums.phpfreaks.com/topic/222676-trim-function/ 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); } ?> Link to comment https://forums.phpfreaks.com/topic/222676-trim-function/#findComment-1151578 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.