note 96740 added to function.array-filter

From: Date: Sat, 13 Mar 2010 16:58:42 +0000
Subject: note 96740 added to function.array-filter
Groups: php.notes 
Request: Send a blank email to php-notes+get-167000@lists.php.net to get a copy of this message
If you're using filter_input_array, the values will be null on failure and anything else on success. Because array_filter by default removes false, 0 and "" you need to do extra work like this: <?php $input_array = filter_input_array(INPUT_GET, array( 'var1' => FILTER_VALIDATE_BOOLEAN, 'var2' => FILTER_VALIDATE_INT )); array_filter($input_array, function($a) { return !is_null($a) }); ?> ---- Server IP: 78.110.173.36 Probable Submitter: 87.254.94.189 ---- Manual Page -- http://www.php.net/manual/en/function.array-filter.php Edit -- https://master.php.net/note/edit/96740 Del: integrated -- https://master.php.net/note/delete/96740/integrated Del: useless -- https://master.php.net/note/delete/96740/useless Del: bad code -- https://master.php.net/note/delete/96740/bad+code Del: spam -- https://master.php.net/note/delete/96740/spam Del: non-english -- https://master.php.net/note/delete/96740/non-english Del: in docs -- https://master.php.net/note/delete/96740/in+docs Del: other reasons-- https://master.php.net/note/delete/96740 Reject -- https://master.php.net/note/reject/96740 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#167000) next »