Count Array Values > 0
<p>I have a form that sends integers up to <code>$_POST['ore']</code> from a table of select boxes and text input fields.  Array in question is:</p>

<pre><code>print_r($_POST)
//returns
Array
(
[ore] =&gt; Array
    (
        [0] =&gt; 1
        [1] =&gt; 2
        [2] =&gt; 0
        [3] =&gt; 0
        [4] =&gt; 0
        [5] =&gt; 0
        [6] =&gt; 0
        [7] =&gt; 0
        [8] =&gt; 0
        [9] =&gt; 0
    )
....
</code></pre>

<p>And that's all the bigger it gets, it's a small application. 10 select boxes, 10 input boxes.  The form itself and the other functions work great.</p>

<p>However, On submit the data is sent to another page that processes the information gathered and generates a new table with a <code>while</code> loop based on the <code>count</code> of that array.  But, I only want to count the values that are greater than 0 as zero is technically empty.</p>

<p>I have tried multiple functions, examples, bits pieces and tried dumb luck too but no positive results.  I have gotten some to work partially, but most of the time they leave out the last row.</p>

<p>I currently have <code>size = count($_POST['ore']);</code> - however this creates a table with 10 rows (as it should) and fills the rest of the rows in the table with the last loop of the while code. Functional, but annoying and not what I would like to do.</p>

<p>I have tried array_filter with</p>

<pre><code>function nonzero($var){
   return ($var &gt; 0); }
$size = array_filter($_POST['ore'], "nonzero");
</code></pre>

<p>No luck.  </p>

<p>I have tried <code>if(isset($_POST['ore']))</code> in multiple places, but since there is a 0 value in the array, it's technically set.</p>

<p>So, how do I count ,or filter then count, the $_POST['ore'] array values to strip away the 0's and only count or return the keys that are greater than 0?</p>

<p>My beat up keyboard and I thank you in advance.</p>

<hr>

<p>Edit - Found the answer thank you all for the feedback this early in the morning</p>

<pre><code>function nonzero($var){
   return ($var &gt; 0); }
$size = count(array_filter($_POST['ore'], "nonzero"));
</code></pre>

<p>^^ that did it</p>
