note 20853 added to function.array-walk

From: Date: Thu, 18 Apr 2002 18:55:26 +0000
Subject: note 20853 added to function.array-walk
Groups: php.notes 
Request: Send a blank email to php-notes+get-29533@lists.php.net to get a copy of this message
This might be overly-obvious, but when using array_walk(), the function being called should not return anything. For example, imagine a function that does a basic clean-up of a form field: function clean_up ($field) { $field = trim($field); $field = strip_tags($field); return $field; } This works just fine when passing it a variable like a single field, but if passing it an array, then you need to remove the return line. function clean_up_array (&$fields_array) { $fields_array = trim($fields_array); $fields_array = strip_tags($fields_array); } -- http://www.php.net/manual/en/function.array-walk.php http://master.php.net/manage/user-notes.php?action=edit+20853 http://master.php.net/manage/user-notes.php?action=delete+20853 http://master.php.net/manage/user-notes.php?action=reject+20853

« previous php.notes (#29533) next »