<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
  <channel>
    <title>Comments on snippet: 'POST or GET data empty check'</title>
    <description>Snipplr comments feed</description>
    <link>https://snipplr.com/</link>
    <lastBuildDate>Tue, 14 Apr 2026 21:51:00 +0000</lastBuildDate>
    <item>
      <title>Sverri said on 21/Dec/2010</title>
      <link>https://snipplr.com/view/39904/post-or-get-data-empty-check</link>
      <description>&lt;p&gt;This function is nonsensical.&#13;
&#13;
The empty() function will return true if the POST or GET arrays are empty. There is no need to loop over the values like this.&lt;/p&gt;</description>
      <pubDate>Tue, 21 Dec 2010 22:10:39 UTC</pubDate>
      <guid>https://snipplr.com/view/39904/post-or-get-data-empty-check</guid>
    </item>
    <item>
      <title>jamepaul said on 23/Dec/2010</title>
      <link>https://snipplr.com/view/39904/post-or-get-data-empty-check</link>
      <description>&lt;p&gt;I don't directly loop POST or GET.&#13;
I use like this.&#13;
&#13;
$val1 = $_POST['val1'];&#13;
$val2 = $_POST['val2'];&#13;
$val4 = $_POST['val3'];&#13;
&#13;
$arr = array($val1, $val2, $val3);&#13;
&#13;
if(check_empty($arr) === false) {&#13;
     // codes here&#13;
}&#13;
&#13;
Any advice?&lt;/p&gt;</description>
      <pubDate>Thu, 23 Dec 2010 17:34:48 UTC</pubDate>
      <guid>https://snipplr.com/view/39904/post-or-get-data-empty-check</guid>
    </item>
    <item>
      <title>Sverri said on 02/Jan/2011</title>
      <link>https://snipplr.com/view/39904/post-or-get-data-empty-check</link>
      <description>&lt;p&gt;Okay, but I am not quite sure in what situation a function like that would be useful.&#13;
&#13;
If you want to know if an array is empty simply use:&#13;
&#13;
    if (empty($array)) {&#13;
        echo "The array is empty";&#13;
    }&#13;
&#13;
&#13;
If you want to know if an array is NOT empty. ("!" means "not" and basically flips boolean values on their heads, so that false becomes true and vice versa):&#13;
&#13;
    if ( ! empty($array)) {&#13;
        echo "The array is NOT empty";&#13;
    }&#13;
&#13;
if you want to know if an array CONTAINS one or more empty values.&#13;
&#13;
    if (in_array(null, $arr)) {&#13;
        echo 'Array contains one or more empty values';&#13;
    }&#13;
&#13;
In PHP if a value can be thought of as empty it is considered to be of the type null: 0 (zero), false (boolean), "" (empty string), array() (empty array), 0.0 (empty decimal number), and so on, are all considered to be null. Be careful, though, to not use === in cases like this, because === also checks for the variable type and then the aforementioned values will not equal null.&#13;
&#13;
Also, you should take a look at PHP's [array functions](http://www.php.net/manual/en/ref.array.php "PHP array functions"). It is rare that you need to define your own functions for use with arrays.&#13;
&#13;
Anyways, so you can do something like this:&#13;
&#13;
    $arr = array($POST['val1'],$POST['val2'],$_POST['val3']);&#13;
    if (in_array(null, $arr)) {&#13;
        echo 'Array contains one or more empty values';&#13;
    }&lt;/p&gt;</description>
      <pubDate>Sun, 02 Jan 2011 07:39:37 UTC</pubDate>
      <guid>https://snipplr.com/view/39904/post-or-get-data-empty-check</guid>
    </item>
    <item>
      <title>SameehaS said on 17/Mar/2024</title>
      <link>https://snipplr.com/view/39904/post-or-get-data-empty-check</link>
      <description>&lt;p&gt;Unlock endless possibilities with our vast collection of software licenses. As the premier destination, we ensure authenticity and reliability in every [mi licence](https://yeslicense.org/) transaction.&lt;/p&gt;</description>
      <pubDate>Sun, 17 Mar 2024 06:29:57 UTC</pubDate>
      <guid>https://snipplr.com/view/39904/post-or-get-data-empty-check</guid>
    </item>
    <item>
      <title>SameehaS said on 08/Apr/2024</title>
      <link>https://snipplr.com/view/39904/post-or-get-data-empty-check</link>
      <description>&lt;p&gt;Trust [Taxi Monaco](https://monaco-taxi-limousine.com/) to provide you with an unparalleled transportation experience in Monaco, boasting experienced drivers and a range of luxurious vehicles.&lt;/p&gt;</description>
      <pubDate>Mon, 08 Apr 2024 10:12:57 UTC</pubDate>
      <guid>https://snipplr.com/view/39904/post-or-get-data-empty-check</guid>
    </item>
    <item>
      <title>SameehaS said on 12/Apr/2024</title>
      <link>https://snipplr.com/view/39904/post-or-get-data-empty-check</link>
      <description>&lt;p&gt;[Fire Extinguishers Limassol](https://www.redfire.com.cy/): Your trusted source for fire safety in Limassol. Our premium extinguishers and expert services ensure reliable protection for your property.&lt;/p&gt;</description>
      <pubDate>Fri, 12 Apr 2024 18:44:19 UTC</pubDate>
      <guid>https://snipplr.com/view/39904/post-or-get-data-empty-check</guid>
    </item>
    <item>
      <title>SameehaS said on 17/Apr/2024</title>
      <link>https://snipplr.com/view/39904/post-or-get-data-empty-check</link>
      <description>&lt;p&gt;Prepare to be dazzled by the brilliance of PG Slots, where innovation, excitement, and big wins come together in perfect harmony. [สล็อต pg เว็บตรง แตกหนัก วอ เลท](https://www.bsc.news/post/7-ewb-sl-t-pg-ewbtrng-aetkhnak-aimphaane-eynt-aimmiikhantam-w-elth-2024)&lt;/p&gt;</description>
      <pubDate>Wed, 17 Apr 2024 12:42:38 UTC</pubDate>
      <guid>https://snipplr.com/view/39904/post-or-get-data-empty-check</guid>
    </item>
  </channel>
</rss>
