Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I don't understand your question very well, but perhaps you're looking for <strong><a href="http://php.net/manual/en/function.array-filter.php" rel="nofollow noreferrer"><code>array_filter()</code></a></strong>?</p> <p><code>array_filter($arr)</code> will return an array with all empty values removed, so in your case only the index 2 with the value of <code>test</code> will be preserved, you could use <code>count()</code> afterwards.</p> <hr> <p>In light of your comment:</p> <pre><code>if (count(array_filter($arr)) &gt; 0) { echo '$arr has values'; } </code></pre> <hr> <p>Beware that if you don't provide the second argument for <code>array_filter()</code> all values that can be converted to false will be dropped, such as <code>0</code>'s. If you want to remove only empty values you can do:</p> <pre><code>if (count(array_filter($arr, 'isset')) &gt; 0) { echo '$arr has values'; } </code></pre> <p>Or (my preferred version):</p> <pre><code>if (count(array_filter($arr, 'strlen')) &gt; 0) { echo '$arr has values'; } </code></pre> <hr> <p><strong>You may also be interested in a <a href="https://stackoverflow.com/questions/1013493/coalesce-function-for-php">Coalesce function for PHP</a>.</strong></p> <hr> <p>In light of your last comment I still think <code>array_filter()</code> works, (assuming <code>$_FILES</code>) try this:</p> <pre><code>if (count(array_filter($_FILES['inputbox']['name'], 'strlen')) &gt; 0) { echo count($_FILES['inputbox']['name']) . ' files'; echo '&lt;br /&gt;'; echo count(array_filter($_FILES['inputbox']['name'], 'strlen')) . ' files set'; } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload