What's the simplest way to check that values aren't empty in 2D array?

Count(array_filter($_POST'x')) === 4 Some Explanation: Empty() is the Opposite of a Boolean Variable array_filter removes all elements that equal false (which is!empty() ) and this count must match the expectation of 4 elements then If the number of elements is defined by the total of elements submitted (empty or not), use count() instead the magic number: if (count(array_filter($_POST'x')) === count($_POST'x')) { echo 'No empty elements in $_POST"x"! '; }.

Count(array_filter($_POST'x')) === 4 Some Explanation: Empty() is the Opposite of a Boolean Variable, array_filter removes all elements that equal false (which is!empty()) and this count must match the expectation of 4 elements then. If the number of elements is defined by the total of elements submitted (empty or not), use count() instead the magic number: if (count(array_filter($_POST'x')) === count($_POST'x')) { echo 'No empty elements in $_POST"x"! '; }.

I don't need to check count of them. I need to check emptiness. – daGrevis Jul 13 at 15:41 2 @daGrevis array_filter (without a callback passed) returns an array of values from $_POST'a' that are!

= false. Hakre is then just getting a count of that result array. If the count of that result array matches the count of the original array, then there are no empty values.

– Jonathan Kuhn Jul 13 at 15:46 @daGrevis: It checks for the count of non-empty elements. – hakre Jul 13 at 15:52 Hmm... on Kohana: Fatal error: Class declarations may not be nested in ...\system\classes\date. Php on line 3.

– daGrevis Jul 13 at 15:55 @hakre Somehow. Without new code in if statement all works. Now I'm trying to figure out is it PHP, Kohana or my error.

– daGrevis Jul 13 at 16:11.

Function all_empty($v,$w){ $v . = $w; return $v; } if(array_reduce($_POST'x','all_empty','')==''){ I haven't tested, but you can give this a try.

You can even make the function recursive: if(is_array($w)) $w = array_reduce($w,'all_empty',$v); – Fabrizio Jul 13 at 15:46.

EDIT: (in response to comments) You can encapsulate the "uncool" logic in a function and call it with a one-liner: if ( check_for_empty_values( $_POST ) ) { // Do something } The encapsulated checking logic: function check_for_empty_values( $data ) { $valid = true; foreach ( $data as $element ) { if ( is_array( $element) ) { foreach ( $element as $subelement ) { if ( empty( $subelement ) ) { $valid = false; } } } } return $valid; }.

This will only check one element at a time. – Phil Jul 13 at 15:42 This is basic way to do it. I'm looking for something more cool!

=P I will accept this answer if none will came up with anything better... – daGrevis Jul 13 at 15:42 @deGrevis: See my updated answer for a way to address both form and substance. – George Cummins Jul 13 at 15:49.

For($_POST as $key => $value) { if(!empty($value) ) { // Do stuff. } }.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions