0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

自分用メモ: empty可変長引数Ver.

Last updated at Posted at 2022-05-13

まえがき

isset()は可変長引数対応なのにempty()は対応してない!どうして!と思ったので。
n番煎じだったらゆるして

コード

function_emptyAny.php
function emptyAny(mixed ...$vars) {
    foreach ($vars as $v) {
        if (empty($v)) return true;
    }
    return false;
}

あとがき

emptyAny()は引数のうち一つでも空のものがあればtrue、すべて格納されていればfalseを返す。
アンケートフォームのサーバーサイドバリデーションにつかいました!!!

コメントより

コメント欄にarray_filter()使ったもっと便利な方法あるから見て!!!ありがとうございます!!

0
0
2

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?