note 90617 modified in function.array-filter by danbrown

From: Date: Thu, 30 Apr 2009 16:36:48 +0000
Subject: note 90617 modified in function.array-filter by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-154053@lists.php.net to get a copy of this message
I use the following to see if a array consist of scalar values or null, but of course you could mix it up using any of the is_ functions. <?php if(count($data) !== count(array_filter($data, 'is_scalar') + array_filter($data, 'is_null'))) { throw new Exception('Array did not consist of scalar and null values'); } ?> --was-- I use the following to see if a array consist of scalar values or null, but of course you could mix it up using any of the is_ functions. if(count($data) !== count(array_filter($data, 'is_scalar') + array_filter($data, 'is_null'))) { throw new Exception('Array did not consist of scalar and null values'); } http://php.net/manual/en/function.array-filter.php

« previous php.notes (#154053) next »